zsh-workers
 help / color / mirror / code / Atom feed
From: Tanaka Akira <akr@m17n.org>
To: zsh-workers@sunsite.auc.dk
Subject: mere and _mere
Date: 15 Dec 2000 23:38:44 +0900	[thread overview]
Message-ID: <hvobsudpx57.fsf@coulee.m17n.org> (raw)

I found that Functions/Misc/mere is useful.  But it's not powerful as
I want.  So I rewroted it and write _mere for its completion.

Index: Functions/Misc/mere
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Misc/mere,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 mere
--- Functions/Misc/mere	1999/06/08 09:26:06	1.1.1.1
+++ Functions/Misc/mere	2000/12/15 14:34:27
@@ -1,3 +1,83 @@
-#! /bin/sh
-# read a man page in the current directory
-nroff -man -Tman $1 | less -s
+# read a man page
+
+setopt localoptions extendedglob
+
+local manual="$1" col=col terminal=man magic line
+
+# /usr/bin/col on SunOS 4 doesn't support -x.
+if [[ -x /usr/5bin/col ]]; then
+  col=/usr/5bin/col;
+fi
+
+# SunOS 5 has no `man' terminal.
+if [[ -d /usr/share/lib/nterm &&
+    ! -e /usr/share/lib/nterm/tab.$terminal ]]; then
+  terminal=lp;
+fi
+
+# HP-UX has no `man' terminal.
+if [[ -d /usr/share/lib/term &&
+    ! -e /usr/share/lib/term/tab$terminal ]]; then
+  terminal=lp;
+fi
+
+# Unixware has no `man' terminal.
+if [[ -d /usr/ucblib/doctools/nterm &&
+    ! -e /usr/ucblib/doctools/nterm/tab.$terminal ]]; then
+  terminal=lp;
+fi
+
+# Solaris has SGML manuals.
+if [[ -f /usr/lib/sgml/sgml2roff ]] && 
+   [[ "$(read -er < $manual)" = "<!DOCTYPE"* ]]; then
+  /usr/lib/sgml/sgml2roff $manual | {
+    read -r line
+    if [[ $line = ".so "* ]]; then
+      # There is no cascading .so directive.
+      # On Solaris 7, at least.
+      /usr/lib/sgml/sgml2roff ${line#.so }
+    else
+      print -lr - "$line"
+      cat
+    fi
+  }
+else
+  read -u0 -k 2 magic < $manual
+  case $magic in
+  $'\037\235') zcat $manual;;
+  $'\037\213') gzip -dc $manual;;
+  *) cat $manual;;
+  esac
+fi | (
+  # cd is required to work soelim called by nroff.
+  case $manual in
+  */man/man*/*) cd ${manual:h:h};;
+  */man/sman*/*) cd ${manual:h:h};;
+  esac
+  read -r line
+  # The first line beginning with '\" shows preprocessors.
+  # Unknown preprocessors is ignored.
+  if [[ $line = "'\\\" "* ]]; then
+    typeset -A filter
+    filter=(
+      e neqn
+      g grap
+      p pic
+      r refer
+      t tbl
+      v vgrind
+    )
+    eval ${(j:|:)${${(s::)line#\'\\\" }//(#m)?/$filter[$MATCH]}}
+  elif [[ $line = "'\\\"! "* ]]; then
+    typeset -A filter
+    filter=(
+      eqn neqn
+    )
+    eval ${(j:|:)${${${${(s:|:)line#\'\\\"! }# ##}% ##}//(#m)*/$filter[$MATCH]}}
+  else
+    print -lr - "$line"
+    cat
+  fi |
+  nroff -T$terminal -man | $col -x
+) |
+${MANPAGER:-${PAGER:-more}} -s
Index: Completion/User/_mere
===================================================================
RCS file: _mere
diff -N _mere
--- /dev/null	Tue May  5 13:32:27 1998
+++ _mere	Fri Dec 15 06:34:27 2000
@@ -0,0 +1,3 @@
+#compdef mere
+
+_files -g '*.[1-9]([a-z]|) *.man'
-- 
Tanaka Akira


             reply	other threads:[~2000-12-15 14:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-15 14:38 Tanaka Akira [this message]
2000-12-15 15:54 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=hvobsudpx57.fsf@coulee.m17n.org \
    --to=akr@m17n.org \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).