jv@mh.nl (Johan Vromans) (07/01/90)
[Repeat after me: never hack an existing source and think that you can obtain something quick & easy...] This is version 1.5 of describe-perl-symbol. It is a complete set, since the diffs would be much more than the new sources. Changes since 1.4: * restructured doc file (allow more info to be found) * rewrote perl-symbol-at-point. Now it matches symbols at the end of line, and much more. * eliminated the perl-mode-syntax-table completely. * added doc for if/while/until/for/foreach/do. ---- Cut Here and unpack ---- #!/bin/sh # This is perldescr, a shell archive (shar 3.24) # made 06/30/1990 11:59 UTC by jv@squirrel # Source directory /u/jv/elisp/src/perldescr # # existing files WILL be overwritten # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 2665 -r--r--r-- perl-descr.el # 7908 -r--r--r-- perl-descr.txt # if touch 2>&1 | fgrep '[-amc]' > /dev/null then TOUCH=touch else TOUCH=true fi # ============= perl-descr.el ============== echo "x - extracting perl-descr.el (Text)" sed 's/^X//' << 'SHAR_EOF' > perl-descr.el && X;; @(#)@ perl-descr.el 1.5 - describe-perl-symbol X X;; This file defines the function 'describe-perl-symbol, which X;; displays a one-line information on a perl symbol. X X;; Based on 'describe-lisp-symbol' and others. X;; Hacked for Perl by Johan Vromans <jv@mh.nl> X X(defvar perl-doc-file "~/elisp/perl-descr.txt" X "*Where the documentation file can be found.") X X(defun perl-symbol-at-point () X "Get the closest Perl symbol to point, but don't change your Xposition. Has a preference for looking backward when not Xdirectly on a symbol." X X (let ((perl-wordchars "a-zA-Z0-9_") start end symbol) X X (save-excursion X X ;; first see if you're just past a symbol X (if (not (eobp)) X (if (looking-at "[] \t\n[{}()]") X (progn X (skip-chars-backward " \n\t\r({[]})") X (if (not (bobp)) X (backward-char 1))))) X X (if (string-match (concat "[" perl-wordchars "]") X (char-to-string (following-char))) X (progn X (skip-chars-backward perl-wordchars) X (setq start (point)) X ; Get identifier. Include leading $ % @ to find things like X ; @ARGV and %ENV . X (if (string-match "[$%@]" (char-to-string (preceding-char))) X (setq start (1- start))) X (skip-chars-forward perl-wordchars)) X X ;; else a symbol? X (progn X (setq start (point)) X (if (looking-at "[$@][^ \n\t]") ; special variable X (forward-char 1) X (if (string-match "[$@]" (char-to-string (preceding-char))) X (setq start (1- start)))) X (forward-char 1))) X (buffer-substring start (point))))) X X(defun describe-perl-symbol (symbol) X "Display the documentation of SYMBOL, a Perl operator." X (interactive X (let ((fn (perl-symbol-at-point)) X (enable-recursive-minibuffers t) X (case-fold-search nil) ;require that case match for search X val args-file regexp) X (setq val (read-from-minibuffer X (if fn X (format "Symbol (default %s): " fn) X "Symbol: "))) X (if (string= val "") X (setq val fn)) X (setq regexp (concat "^" (regexp-quote val) "\\([ \t([/]\\|$\\)")) X X ;; get the buffer with the documentation text X (if (not (get-file-buffer perl-doc-file)) X (progn X (setq args-file X (find-file-noselect perl-doc-file)) X (set-buffer args-file) X (rename-buffer "*PERL-DOC*") X (setq buffer-read-only t))) X (set-buffer (get-file-buffer perl-doc-file)) X X ;; lookup in the doc X (goto-char (point-min)) X (list (if (re-search-forward regexp (point-max) t) X (save-excursion X (beginning-of-line 1) X (let ((lnstart (point))) X (end-of-line) X (message "%s" (buffer-substring lnstart (point))))) X (error (format "No definition for %s" val))))))) SHAR_EOF $TOUCH -am 0630135190 perl-descr.el && chmod 0444 perl-descr.el || echo "restore of perl-descr.el failed" set `wc -c perl-descr.el`;Wc_c=$1 if test "$Wc_c" != "2665"; then echo original size 2665, current size $Wc_c fi # ============= perl-descr.txt ============== echo "x - extracting perl-descr.txt (Text)" sed 's/^X//' << 'SHAR_EOF' > perl-descr.txt && X# @(#)@ perl-descr.txt 1.5 - describe-perl-symbol [text] X!= Numeric inequality. X!~ Search pattern, substitution, or translation (negated). X$! If used in a numeric context, yields the current value of errno. If used in a string context, yields the corresponding error string. X$" The separator which joins elements of arrays interpolated in strings. X$# The output format for printed numbers. Initial value is %.20g. X$$ The process number of the perl running this script. Altered (in the child process) by fork(). X$% The current page number of the currently selected output channel. X$& The string matched by the last pattern match. X$' The string following what was matched by the last pattern match. X$( The real gid of this process. X$) The effective gid of this process. X$* Set to 1 to do multiline matching within a string, 0 to assume strings contain a single line. Default is 0. X$+ The last bracket matched by the last search pattern. X$, The output field separator for the print operator. X$- The number of lines left on the page. X$. The current input line number of the last filehandle that was read. X$/ The input record separator, newline by default. X$0 The name of the file containing the perl script being executed. X$1..$9 Contains the subpattern from the corresponding set of parentheses in the last pattern matched. X$: The set of characters after which a string may be broken to fill continuation fields (starting with ^) in a format. X$; The subscript separator for multi-dimensional array emulation. Default is "\034". X$< The real uid of this process. X$= The page length of the current output channel. Default is 60 lines. X$> The effective uid of this process. X$? The status returned by the last backtick (``) command, pipe close or system operator. X$@ The perl error message from the last eval or do @var{EXPR} command. X$[ The index of the first element in an array, and of the first character in a substring. Default is 0. X$\ The output record separator for the print operator. X$] The perl version string as displayed with perl -v. X$^ The name of the current top-of-page format. X$_ The default input and pattern-searching space. X$` The string preceding what was matched by the last pattern match. X$| If set to nonzero, forces a flush after every write or print on the currently selected output channel. Default is 0. The following variables are always local to the current block: X$~ The name of the current report format. X% Modulo division. X%ENV Contains the current environment. X%SIG Used to set signal handlers for various signals. X& Bitwise and. && Logical and. X&& Logical and. X* Multiplication. ** Exponentiation, X** Exponentiation. X+ Addition. ++ Auto-increment X++ Auto-increment (magical on strings). X, Comma operator. X- Subtraction. -- Auto-decrement. X-- Auto-decrement. X-B File is a non-text (binary) file. X-O File is owned by real uid. X-R File is readable by real uid. X-S File is a socket . X-T File is a text file. X-W File is writable by real uid. X-X File is executable by real uid. X-b File is a block special file. X-c File is a character special file. X-d File is a directory. X-e File exists . X-f File is a plain file. X-g File has setgid bit set. X-k File has sticky bit set. X-l File is a symbolic link. X-o File is owned by effective uid. X-p File is a named pipe (FIFO). X-r File is readable by effective uid. X-s File has non-zero size. X-t Tests if filehandle (STDIN by default) is opened to a tty. X-u File has setuid bit set. X-w File is writable by effective uid. X-x File is executable by effective uid. X-z File has zero size. X. Concatenate strings. .. Alternation, also range operator. X.. Alternation, also range operator. X/ Division. /PATTERN/io Pattern match X/PATTERN/io X< Numeric less than. << Bitwise shift left. X<< Bitwise shift left. X<= Numeric less than or equal to. X== Numeric equality. =~ Search pattern, substitution, or translation.=~ Search pattern, substitution, or translation. X> Numeric greater than. >= Numeric greater than or equal to. X>= Numeric greater than or equal to. >> Bitwise shift right. X>> Bitwise shift right. X? : Alternation (if-then-else) operator. ?PATTERN? Backwards pattern match X@ARGV Contains the command line arguments for the script (not including the command name). See $0 for the command name. X@INC Contains the list of places to look for perl scripts to be evaluated by the do EXPR command. X@_ Parameter array for subroutines. Also used by split if not in array context. X^ Bitwise exclusive or. Xaccept(NEWSOCKET,GENERICSOCKET) Xatan2(X,Y) Xbind(SOCKET,NAME) Xbinmode(FILEHANDLE) Xchdir(EXPR) Xchmod(LIST) Xchop[(LIST|VAR)] Xchown(LIST) Xchroot(FILENAME) Xclose(FILEHANDLE) Xclosedir(DIRHANDLE) Xconnect(SOCKET,NAME) Xcos(EXPR) Xcrypt(PLAINTEXT,SALT) Xdbmclose(ASSOC_ARRAY) Xdbmopen(ASSOC,DBNAME,MODE) Xdefined(EXPR) Xdelete($ASSOC{KEY}) Xdie(LIST) Xdo(EXPR|SUBR([LIST])) Xdo { ... } while|until EXPR executes at least once Xdump(LABEL) Xeach(ASSOC_ARRAY) Xendgrent Xendhostent Xendnetent Xendprotoent Xendpwent Xendservent Xeof[([FILEHANDLE])] Xeq String equality. Xeval(EXPR) Xexec(LIST) Xexit(EXPR) Xexp(EXPR) Xfcntl(FILEHANDLE,FUNCTION,SCALAR) Xfileno(FILEHANDLE) Xflock(FILEHANDLE,OPERATION) Xfor (EXPR;EXPR;EXPR) { ... } Xforeach [VAR] (@ARRAY) { ... } Xfork Xge String greater than or equal. Xgetc[(FILEHANDLE)] Xgetgrent Xgetgrgid(GID) Xgetgrnam(NAME) Xgethostbyaddr(ADDR,ADDRTYPE) Xgethostbyname(NAME) Xgethostent Xgetlogin Xgetnetbyaddr(ADDR,ADDRTYPE) Xgetnetbyname(NAME) Xgetnetent Xgetpeername(SOCKET) Xgetpgrp(PID) Xgetppid Xgetpriority(WHICH,WHO) Xgetprotobyname(NAME) Xgetprotobynumber(NUMBER) Xgetprotoent Xgetpwent Xgetpwnam(NAME) Xgetpwuid(UID) Xgetservbyname(NAME,PROTO) Xgetservbyport(PORT,PROTO) Xgetservent Xgetsockname(SOCKET) Xgetsockopt(SOCKET,LEVEL,OPTNAME) Xgmtime(EXPR) Xgoto(LABEL) Xgrep(EXPR,LIST) Xgt String greater than. Xhex(EXPR) Xif (EXPR) { ... } [ elsif (EXPR) { ... } ... ] [ else { ... } ] or EXPR if EXPR Xindex(STR,SUBSTR) Xint(EXPR) Xioctl(FILEHANDLE,FUNCTION,SCALAR) Xjoin(EXPR,LIST) Xkeys(ASSOC_ARRAY) Xkill(LIST) Xlast[(LABEL)] Xle String less than or equal. Xlength(EXPR) Xlink(OLDFILE,NEWFILE) Xlisten(SOCKET,QUEUESIZE) Xlocal(LIST) Xlocaltime(EXPR) Xlog(EXPR) Xlstat(EXPR|FILEHANDLE|VAR) Xlt String less than. Xm/PATTERN/io Xmkdir(FILENAME,MODE) Xne String inequality. Xnext[(LABEL)] Xoct(EXPR) Xopen(FILEHANDLE[,EXPR]) Xopendir(DIRHANDLE,EXPR) Xord(EXPR) Xpack(TEMPLATE,LIST) Xpipe(READHANDLE,WRITEHANDLE) Xpop(ARRAY) Xprint[(FILEHANDLE [LIST])] Xprintf([FILEHANDLE] LIST) Xpush(ARRAY,LIST) Xq/STRING/ Xqq/STRING/ Xrand[(EXPR)] Xread(FILEHANDLE,SCALAR,LENGTH) Xreaddir(DIRHANDLE) Xreadlink(EXPR) Xrecv(SOCKET,SCALAR,LEN,FLAGS) Xredo[(LABEL)] Xrename(OLDNAME,NEWNAME) Xreset[(EXPR)] Xreturn(LIST) Xreverse(LIST) Xrewinddir(DIRHANDLE) Xrindex(STR,SUBSTR) Xrmdir(FILENAME) Xs/PATTERN/REPLACEMENT/gieo Xseek(FILEHANDLE,POSITION,WHENCE) Xseekdir(DIRHANDLE,POS) Xselect(FILEHANDLE | RBITS,WBITS,EBITS,TIMEOUT) Xsend(SOCKET,MSG,FLAGS[,TO]) Xsetgrent Xsethostent(STAYOPEN) Xsetnetent(STAYOPEN) Xsetpgrp(PID,PGRP) Xsetpriority(WHICH,WHO,PRIORITY) Xsetprotoent(STAYOPEN) Xsetpwent Xsetservent(STAYOPEN) Xsetsockopt(SOCKET,LEVEL,OPTNAME,OPTVAL) Xshift[(ARRAY)] Xshutdown(SOCKET,HOW) Xsin(EXPR) Xsleep[(EXPR)] Xsocket(SOCKET,DOMAIN,TYPE,PROTOCOL) Xsocketpair(SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL) Xsort([SUBROUTINE] LIST) Xsplice(ARRAY,OFFSET[,LENGTH[,LIST]]) Xsplit[(/PATTERN/[,EXPR[,LIMIT]])] Xsprintf(FORMAT,LIST) Xsqrt(EXPR) Xsrand(EXPR) Xstat(EXPR|FILEHANDLE|VAR) Xstudy[(SCALAR)] Xsubstr(EXPR,OFFSET,LEN) Xsymlink(OLDFILE,NEWFILE) Xsyscall(LIST) Xsystem(LIST) Xtell[(FILEHANDLE)] Xtelldir(DIRHANDLE) Xtime Xtimes Xtr/SEARCHLIST/REPLACEMENTLIST/ Xumask[(EXPR)] Xundef[(EXPR)] Xunless (EXPR) { ... } [ else { ... } ] or EXPR unless EXPR Xunlink(LIST) Xunpack(TEMPLATE,EXPR) Xunshift(ARRAY,LIST) Xuntil (EXPR) { ... } or EXPR until EXPR Xutime(LIST) Xvalues(ASSOC_ARRAY) Xvec(EXPR,OFFSET,BITS) Xwait Xwantarray Xwarn(LIST) Xwhile (EXPR) { ... } or EXPR while EXPR Xwrite[(EXPR|FILEHANDLE)] Xx Repeat string. Xy/SEARCHLIST/REPLACEMENTLIST/ X| Bitwise or. || Logical or. X|| Logical or. SHAR_EOF $TOUCH -am 0630135290 perl-descr.txt && chmod 0444 perl-descr.txt || echo "restore of perl-descr.txt failed" set `wc -c perl-descr.txt`;Wc_c=$1 if test "$Wc_c" != "7908"; then echo original size 7908, current size $Wc_c fi exit 0 -- Johan Vromans jv@mh.nl via internet backbones Multihouse Automatisering bv uucp: ..!{uunet,hp4nl}!mh.nl!jv Doesburgweg 7, 2803 PL Gouda, The Netherlands phone/fax: +31 1820 62911/62500 ------------------------ "Arms are made for hugging" -------------------------