home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / functions / perl-descr.shar / text0000.txt < prev   
Encoding:
Text File  |  1990-07-22  |  12.6 KB  |  408 lines

  1. [Repeat after me: never hack an existing source and think that you can
  2.  obtain something quick & easy...]
  3.  
  4. This is version 1.5 of describe-perl-symbol. It is a complete set,
  5. since the diffs would be much more than the new sources.
  6.  
  7. Changes since 1.4:
  8.  
  9.   * restructured doc file (allow more info to be found)
  10.   * rewrote perl-symbol-at-point. Now it matches symbols at the end
  11.     of line, and much more.
  12.   * eliminated the perl-mode-syntax-table completely.
  13.   * added doc for if/while/until/for/foreach/do.
  14.  
  15. ---- Cut Here and unpack ----
  16. #!/bin/sh
  17. # This is perldescr, a shell archive (shar 3.24)
  18. # made 06/30/1990 11:59 UTC by jv@squirrel
  19. # Source directory /u/jv/elisp/src/perldescr
  20. #
  21. # existing files WILL be overwritten
  22. #
  23. # This shar contains:
  24. # length  mode       name
  25. # ------ ---------- ------------------------------------------
  26. #   2665 -r--r--r-- perl-descr.el
  27. #   7908 -r--r--r-- perl-descr.txt
  28. #
  29. if touch 2>&1 | fgrep '[-amc]' > /dev/null
  30.  then TOUCH=touch
  31.  else TOUCH=true
  32. fi
  33. # ============= perl-descr.el ==============
  34. echo "x - extracting perl-descr.el (Text)"
  35. sed 's/^X//' << 'SHAR_EOF' > perl-descr.el &&
  36. X;; @(#)@ perl-descr.el    1.5 - describe-perl-symbol
  37. X
  38. X;; This file defines the function 'describe-perl-symbol, which
  39. X;; displays a one-line information on a perl symbol.
  40. X
  41. X;; Based on 'describe-lisp-symbol' and others.
  42. X;; Hacked for Perl by Johan Vromans <jv@mh.nl>
  43. X
  44. X(defvar perl-doc-file "~/elisp/perl-descr.txt"
  45. X  "*Where the documentation file can be found.")
  46. X
  47. X(defun perl-symbol-at-point ()
  48. X  "Get the closest Perl symbol to point, but don't change your
  49. Xposition. Has a preference for looking backward when not
  50. Xdirectly on a symbol."
  51. X
  52. X  (let ((perl-wordchars "a-zA-Z0-9_") start end symbol)
  53. X          
  54. X    (save-excursion
  55. X
  56. X      ;; first see if you're just past a symbol
  57. X      (if (not (eobp))
  58. X      (if (looking-at "[] \t\n[{}()]")
  59. X          (progn
  60. X        (skip-chars-backward " \n\t\r({[]})")
  61. X        (if (not (bobp))
  62. X            (backward-char 1)))))
  63. X
  64. X      (if (string-match (concat "[" perl-wordchars "]")
  65. X            (char-to-string (following-char)))
  66. X      (progn
  67. X        (skip-chars-backward perl-wordchars)
  68. X        (setq start (point))
  69. X        ; Get identifier. Include leading $ % @ to find things like
  70. X        ; @ARGV and %ENV .
  71. X        (if (string-match "[$%@]" (char-to-string (preceding-char)))
  72. X        (setq start (1- start)))
  73. X        (skip-chars-forward perl-wordchars))
  74. X
  75. X    ;; else a symbol?
  76. X      (progn
  77. X        (setq start (point))
  78. X        (if (looking-at "[$@][^ \n\t]") ; special variable
  79. X        (forward-char 1)
  80. X          (if (string-match "[$@]" (char-to-string (preceding-char)))
  81. X          (setq start (1- start))))
  82. X        (forward-char 1)))
  83. X      (buffer-substring start (point)))))
  84. X
  85. X(defun describe-perl-symbol (symbol)
  86. X  "Display the documentation of SYMBOL, a Perl operator."
  87. X  (interactive
  88. X    (let ((fn (perl-symbol-at-point))
  89. X      (enable-recursive-minibuffers t)
  90. X      (case-fold-search nil)    ;require that case match for search
  91. X      val args-file regexp)
  92. X      (setq val (read-from-minibuffer
  93. X          (if fn
  94. X              (format "Symbol (default %s): " fn)
  95. X            "Symbol: ")))
  96. X      (if (string= val "")
  97. X      (setq val fn))
  98. X      (setq regexp (concat "^" (regexp-quote val) "\\([ \t([/]\\|$\\)"))
  99. X
  100. X      ;; get the buffer with the documentation text
  101. X      (if (not (get-file-buffer perl-doc-file))
  102. X      (progn
  103. X        (setq args-file
  104. X          (find-file-noselect perl-doc-file))
  105. X        (set-buffer args-file)
  106. X        (rename-buffer "*PERL-DOC*")
  107. X        (setq buffer-read-only t)))
  108. X      (set-buffer (get-file-buffer perl-doc-file))
  109. X
  110. X      ;; lookup in the doc
  111. X      (goto-char (point-min))
  112. X      (list (if (re-search-forward regexp (point-max) t)
  113. X        (save-excursion
  114. X          (beginning-of-line 1)
  115. X          (let ((lnstart (point)))
  116. X            (end-of-line)
  117. X            (message "%s" (buffer-substring lnstart (point)))))
  118. X          (error (format "No definition for %s" val)))))))
  119. SHAR_EOF
  120. $TOUCH -am 0630135190 perl-descr.el &&
  121. chmod 0444 perl-descr.el ||
  122. echo "restore of perl-descr.el failed"
  123. set `wc -c perl-descr.el`;Wc_c=$1
  124. if test "$Wc_c" != "2665"; then
  125.     echo original size 2665, current size $Wc_c
  126. fi
  127. # ============= perl-descr.txt ==============
  128. echo "x - extracting perl-descr.txt (Text)"
  129. sed 's/^X//' << 'SHAR_EOF' > perl-descr.txt &&
  130. X# @(#)@ perl-descr.txt 1.5 - describe-perl-symbol [text]
  131. X!=    Numeric inequality.
  132. X!~    Search pattern, substitution, or translation (negated).
  133. X$!    If used in a numeric context, yields the current value of errno. If used in a string context, yields the corresponding error string.
  134. X$"    The separator which joins elements of arrays interpolated in strings.
  135. X$#    The output format for printed numbers. Initial value is %.20g.
  136. X$$    The process number of the perl running this script. Altered (in the child process) by fork().
  137. X$%    The current page number of the currently selected output channel.
  138. X$&    The string matched by the last pattern match.
  139. X$'    The string following what was matched by the last pattern match.
  140. X$(    The real gid of this process.
  141. X$)    The effective gid of this process.
  142. X$*    Set to 1 to do multiline matching within a string, 0 to assume strings contain a single line. Default is 0.
  143. X$+    The last bracket matched by the last search pattern.
  144. X$,    The output field separator for the print operator.
  145. X$-    The number of lines left on the page.
  146. X$.    The current input line number of the last filehandle that was read.
  147. X$/    The input record separator, newline by default.
  148. X$0    The name of the file containing the perl script being executed.
  149. X$1..$9    Contains the subpattern from the corresponding set of parentheses in the last pattern matched.
  150. X$:    The set of characters after which a string may be broken to fill continuation fields (starting with ^) in a format.
  151. X$;    The subscript separator for multi-dimensional array emulation. Default is "\034".
  152. X$<    The real uid of this process.
  153. X$=    The page length of the current output channel. Default is 60 lines.
  154. X$>    The effective uid of this process.
  155. X$?    The status returned by the last backtick (``) command, pipe close or system operator.
  156. X$@    The perl error message from the last eval or do @var{EXPR} command.
  157. X$[    The index of the first element in an array, and of the first character in a substring. Default is 0.
  158. X$\    The output record separator for the print operator.
  159. X$]    The perl version string as displayed with perl -v.
  160. X$^    The name of the current top-of-page format.
  161. X$_    The default input and pattern-searching space.
  162. X$`    The string preceding what was matched by the last pattern match.
  163. 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:
  164. X$~    The name of the current report format.
  165. X%    Modulo division.
  166. X%ENV    Contains the current environment.
  167. X%SIG    Used to set signal handlers for various signals.
  168. X&    Bitwise and.    && Logical and.
  169. X&&    Logical and.
  170. X*    Multiplication.    ** Exponentiation,
  171. X**    Exponentiation.
  172. X+    Addition.    ++ Auto-increment
  173. X++    Auto-increment (magical on strings).
  174. X,    Comma operator.
  175. X-    Subtraction.    -- Auto-decrement.
  176. X--    Auto-decrement.
  177. X-B    File is a non-text (binary) file.
  178. X-O    File is owned by real uid.
  179. X-R    File is readable by real uid.
  180. X-S    File is a socket .
  181. X-T    File is a text file.
  182. X-W    File is writable by real uid.
  183. X-X    File is executable by real uid.
  184. X-b    File is a block special file.
  185. X-c    File is a character special file.
  186. X-d    File is a directory.
  187. X-e    File exists .
  188. X-f    File is a plain file.
  189. X-g    File has setgid bit set.
  190. X-k    File has sticky bit set.
  191. X-l    File is a symbolic link.
  192. X-o    File is owned by effective uid.
  193. X-p    File is a named pipe (FIFO).
  194. X-r    File is readable by effective uid.
  195. X-s    File has non-zero size.
  196. X-t    Tests if filehandle (STDIN by default) is opened to a tty.
  197. X-u    File has setuid bit set.
  198. X-w    File is writable by effective uid.
  199. X-x    File is executable by effective uid.
  200. X-z    File has zero size.
  201. X.    Concatenate strings.    ..    Alternation, also range operator.
  202. X..    Alternation, also range operator.
  203. X/    Division.    /PATTERN/io    Pattern match
  204. X/PATTERN/io
  205. X<    Numeric less than.    <<    Bitwise shift left.
  206. X<<    Bitwise shift left.
  207. X<=    Numeric less than or equal to.
  208. X==    Numeric equality.    =~    Search pattern, substitution, or translation.=~    Search pattern, substitution, or translation.
  209. X>    Numeric greater than.    >=    Numeric greater than or equal to.
  210. X>=    Numeric greater than or equal to.    >>    Bitwise shift right.
  211. X>>    Bitwise shift right.
  212. X? :    Alternation (if-then-else) operator.    ?PATTERN?    Backwards pattern match
  213. X@ARGV    Contains the command line arguments for the script (not including the command name). See $0 for the command name.
  214. X@INC    Contains the list of places to look for perl scripts to be evaluated by the do EXPR command.
  215. X@_    Parameter array for subroutines. Also used by split if not in array context.
  216. X^    Bitwise exclusive or.
  217. Xaccept(NEWSOCKET,GENERICSOCKET)
  218. Xatan2(X,Y)
  219. Xbind(SOCKET,NAME)
  220. Xbinmode(FILEHANDLE)
  221. Xchdir(EXPR)
  222. Xchmod(LIST)
  223. Xchop[(LIST|VAR)]
  224. Xchown(LIST)
  225. Xchroot(FILENAME)
  226. Xclose(FILEHANDLE)
  227. Xclosedir(DIRHANDLE)
  228. Xconnect(SOCKET,NAME)
  229. Xcos(EXPR)
  230. Xcrypt(PLAINTEXT,SALT)
  231. Xdbmclose(ASSOC_ARRAY)
  232. Xdbmopen(ASSOC,DBNAME,MODE)
  233. Xdefined(EXPR)
  234. Xdelete($ASSOC{KEY})
  235. Xdie(LIST)
  236. Xdo(EXPR|SUBR([LIST]))
  237. Xdo { ... } while|until EXPR    executes at least once
  238. Xdump(LABEL)
  239. Xeach(ASSOC_ARRAY)
  240. Xendgrent
  241. Xendhostent
  242. Xendnetent
  243. Xendprotoent
  244. Xendpwent
  245. Xendservent
  246. Xeof[([FILEHANDLE])]
  247. Xeq    String equality.
  248. Xeval(EXPR)
  249. Xexec(LIST)
  250. Xexit(EXPR)
  251. Xexp(EXPR)
  252. Xfcntl(FILEHANDLE,FUNCTION,SCALAR)
  253. Xfileno(FILEHANDLE)
  254. Xflock(FILEHANDLE,OPERATION)
  255. Xfor (EXPR;EXPR;EXPR) { ... }
  256. Xforeach [VAR] (@ARRAY) { ... }
  257. Xfork
  258. Xge    String greater than or equal.
  259. Xgetc[(FILEHANDLE)]
  260. Xgetgrent
  261. Xgetgrgid(GID)
  262. Xgetgrnam(NAME)
  263. Xgethostbyaddr(ADDR,ADDRTYPE)
  264. Xgethostbyname(NAME)
  265. Xgethostent
  266. Xgetlogin
  267. Xgetnetbyaddr(ADDR,ADDRTYPE)
  268. Xgetnetbyname(NAME)
  269. Xgetnetent
  270. Xgetpeername(SOCKET)
  271. Xgetpgrp(PID)
  272. Xgetppid
  273. Xgetpriority(WHICH,WHO)
  274. Xgetprotobyname(NAME)
  275. Xgetprotobynumber(NUMBER)
  276. Xgetprotoent
  277. Xgetpwent
  278. Xgetpwnam(NAME)
  279. Xgetpwuid(UID)
  280. Xgetservbyname(NAME,PROTO)
  281. Xgetservbyport(PORT,PROTO)
  282. Xgetservent
  283. Xgetsockname(SOCKET)
  284. Xgetsockopt(SOCKET,LEVEL,OPTNAME)
  285. Xgmtime(EXPR)
  286. Xgoto(LABEL)
  287. Xgrep(EXPR,LIST)
  288. Xgt    String greater than.
  289. Xhex(EXPR)
  290. Xif (EXPR) { ... } [ elsif (EXPR) { ... } ... ] [ else { ... } ] or EXPR if EXPR
  291. Xindex(STR,SUBSTR)
  292. Xint(EXPR)
  293. Xioctl(FILEHANDLE,FUNCTION,SCALAR)
  294. Xjoin(EXPR,LIST)
  295. Xkeys(ASSOC_ARRAY)
  296. Xkill(LIST)
  297. Xlast[(LABEL)]
  298. Xle    String less than or equal.
  299. Xlength(EXPR)
  300. Xlink(OLDFILE,NEWFILE)
  301. Xlisten(SOCKET,QUEUESIZE)
  302. Xlocal(LIST)
  303. Xlocaltime(EXPR)
  304. Xlog(EXPR)
  305. Xlstat(EXPR|FILEHANDLE|VAR)
  306. Xlt    String less than.
  307. Xm/PATTERN/io
  308. Xmkdir(FILENAME,MODE)
  309. Xne    String inequality.
  310. Xnext[(LABEL)]
  311. Xoct(EXPR)
  312. Xopen(FILEHANDLE[,EXPR])
  313. Xopendir(DIRHANDLE,EXPR)
  314. Xord(EXPR)
  315. Xpack(TEMPLATE,LIST)
  316. Xpipe(READHANDLE,WRITEHANDLE)
  317. Xpop(ARRAY)
  318. Xprint[(FILEHANDLE [LIST])]
  319. Xprintf([FILEHANDLE] LIST)
  320. Xpush(ARRAY,LIST)
  321. Xq/STRING/
  322. Xqq/STRING/
  323. Xrand[(EXPR)]
  324. Xread(FILEHANDLE,SCALAR,LENGTH)
  325. Xreaddir(DIRHANDLE)
  326. Xreadlink(EXPR)
  327. Xrecv(SOCKET,SCALAR,LEN,FLAGS)
  328. Xredo[(LABEL)]
  329. Xrename(OLDNAME,NEWNAME)
  330. Xreset[(EXPR)]
  331. Xreturn(LIST)
  332. Xreverse(LIST)
  333. Xrewinddir(DIRHANDLE)
  334. Xrindex(STR,SUBSTR)
  335. Xrmdir(FILENAME)
  336. Xs/PATTERN/REPLACEMENT/gieo
  337. Xseek(FILEHANDLE,POSITION,WHENCE)
  338. Xseekdir(DIRHANDLE,POS)
  339. Xselect(FILEHANDLE | RBITS,WBITS,EBITS,TIMEOUT)
  340. Xsend(SOCKET,MSG,FLAGS[,TO])
  341. Xsetgrent
  342. Xsethostent(STAYOPEN)
  343. Xsetnetent(STAYOPEN)
  344. Xsetpgrp(PID,PGRP)
  345. Xsetpriority(WHICH,WHO,PRIORITY)
  346. Xsetprotoent(STAYOPEN)
  347. Xsetpwent
  348. Xsetservent(STAYOPEN)
  349. Xsetsockopt(SOCKET,LEVEL,OPTNAME,OPTVAL)
  350. Xshift[(ARRAY)]
  351. Xshutdown(SOCKET,HOW)
  352. Xsin(EXPR)
  353. Xsleep[(EXPR)]
  354. Xsocket(SOCKET,DOMAIN,TYPE,PROTOCOL)
  355. Xsocketpair(SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL)
  356. Xsort([SUBROUTINE] LIST)
  357. Xsplice(ARRAY,OFFSET[,LENGTH[,LIST]])
  358. Xsplit[(/PATTERN/[,EXPR[,LIMIT]])]
  359. Xsprintf(FORMAT,LIST)
  360. Xsqrt(EXPR)
  361. Xsrand(EXPR)
  362. Xstat(EXPR|FILEHANDLE|VAR)
  363. Xstudy[(SCALAR)]
  364. Xsubstr(EXPR,OFFSET,LEN)
  365. Xsymlink(OLDFILE,NEWFILE)
  366. Xsyscall(LIST)
  367. Xsystem(LIST)
  368. Xtell[(FILEHANDLE)]
  369. Xtelldir(DIRHANDLE)
  370. Xtime
  371. Xtimes
  372. Xtr/SEARCHLIST/REPLACEMENTLIST/
  373. Xumask[(EXPR)]
  374. Xundef[(EXPR)]
  375. Xunless (EXPR) { ... } [ else { ... } ] or EXPR unless EXPR
  376. Xunlink(LIST)
  377. Xunpack(TEMPLATE,EXPR)
  378. Xunshift(ARRAY,LIST)
  379. Xuntil (EXPR) { ... } or EXPR until EXPR
  380. Xutime(LIST)
  381. Xvalues(ASSOC_ARRAY)
  382. Xvec(EXPR,OFFSET,BITS)
  383. Xwait
  384. Xwantarray
  385. Xwarn(LIST)
  386. Xwhile  (EXPR) { ... } or EXPR while EXPR
  387. Xwrite[(EXPR|FILEHANDLE)]
  388. Xx    Repeat string.
  389. Xy/SEARCHLIST/REPLACEMENTLIST/
  390. X|    Bitwise or.    ||    Logical or.
  391. X||    Logical or.
  392. SHAR_EOF
  393. $TOUCH -am 0630135290 perl-descr.txt &&
  394. chmod 0444 perl-descr.txt ||
  395. echo "restore of perl-descr.txt failed"
  396. set `wc -c perl-descr.txt`;Wc_c=$1
  397. if test "$Wc_c" != "7908"; then
  398.     echo original size 7908, current size $Wc_c
  399. fi
  400. exit 0
  401. --
  402. Johan Vromans                       jv@mh.nl via internet backbones
  403. Multihouse Automatisering bv               uucp: ..!{uunet,hp4nl}!mh.nl!jv
  404. Doesburgweg 7, 2803 PL Gouda, The Netherlands  phone/fax: +31 1820 62911/62500
  405. ------------------------ "Arms are made for hugging" -------------------------
  406.  
  407.  
  408.