comparison lisp/progmodes/cperl-mode.el @ 22409:382becc612e1

(pod2man-program): Var reinstalled. (cperl-pod-to-manpage, cperl-pod2man-build-command): Fns reinstalled.
author Richard M. Stallman <rms@gnu.org>
date Tue, 09 Jun 1998 04:03:45 +0000
parents cbeef33dd242
children fe5ca8d66639
comparison
equal deleted inserted replaced
22408:500bc7f67524 22409:382becc612e1
6051 (forward-sexp 1) 6051 (forward-sexp 1)
6052 (set-marker e (1- (point))) 6052 (set-marker e (1- (point)))
6053 (cperl-beautify-regexp-piece b e nil))) 6053 (cperl-beautify-regexp-piece b e nil)))
6054 6054
6055 (defun cperl-invert-if-unless () 6055 (defun cperl-invert-if-unless ()
6056 "Changes `if (A) {B}' into `B if A;' if possible." 6056 "Change `if (A) {B}' into `B if A;' if possible."
6057 (interactive) 6057 (interactive)
6058 (or (looking-at "\\<") 6058 (or (looking-at "\\<")
6059 (forward-sexp -1)) 6059 (forward-sexp -1))
6060 (if (looking-at "\\<\\(if\\|unless\\|while\\|until\\)\\>") 6060 (if (looking-at "\\<\\(if\\|unless\\|while\\|until\\)\\>")
6061 (let ((pos1 (point)) 6061 (let ((pos1 (point))
6135 (cperl-indent-line)) 6135 (cperl-indent-line))
6136 (error "`%s' (EXPR) not with an {BLOCK}" s0))) 6136 (error "`%s' (EXPR) not with an {BLOCK}" s0)))
6137 (error "`%s' not with an (EXPR)" s0))) 6137 (error "`%s' not with an (EXPR)" s0)))
6138 (error "Not at `if', `unless', `while', or `unless'"))) 6138 (error "Not at `if', `unless', `while', or `unless'")))
6139 6139
6140 (defvar Man-filter-list) 6140 ;;; Getting help on modules in C-h f ?
6141 ;;; This is a modified version of `man'.
6142 ;;; Need to teach it how to lookup functions
6143 (defun cperl-perldoc (word)
6144 "Run `perldoc' on WORD."
6145 (interactive
6146 (list (let* ((default-entry (cperl-word-at-point))
6147 (input (read-string
6148 (format "perldoc entry%s: "
6149 (if (string= default-entry "")
6150 ""
6151 (format " (default %s)" default-entry))))))
6152 (if (string= input "")
6153 (if (string= default-entry "")
6154 (error "No perldoc args given")
6155 default-entry)
6156 input))))
6157 (let* ((is-func (and
6158 (string-match "^[a-z]+$" word)
6159 (string-match (concat "^" word "\\>")
6160 (documentation-property
6161 'cperl-short-docs
6162 'variable-documentation))))
6163 (manual-program (if is-func "perldoc -f" "perldoc")))
6164 (require 'man)
6165 (Man-getpage-in-background word)))
6166
6167 (defun cperl-perldoc-at-point ()
6168 "Run a `perldoc' on the word around point."
6169 (interactive)
6170 (cperl-perldoc (cperl-word-at-point)))
6171
6172 (defcustom pod2man-program "pod2man"
6173 "*File name for `pod2man'."
6174 :type 'file
6175 :group 'cperl)
6176
6177 (defun cperl-pod-to-manpage ()
6178 "Create a virtual manpage in Emacs from the Perl Online Documentation."
6179 (interactive)
6180 (require 'man)
6181 (let* ((pod2man-args (concat buffer-file-name " | nroff -man "))
6182 (bufname (concat "Man " buffer-file-name))
6183 (buffer (generate-new-buffer bufname)))
6184 (save-excursion
6185 (set-buffer buffer)
6186 (let ((process-environment (copy-sequence process-environment)))
6187 ;; Prevent any attempt to use display terminal fanciness.
6188 (setenv "TERM" "dumb")
6189 (set-process-sentinel
6190 (start-process pod2man-program buffer "sh" "-c"
6191 (format (cperl-pod2man-build-command) pod2man-args))
6192 'Man-bgproc-sentinel)))))
6193
6194 (defun cperl-pod2man-build-command ()
6195 "Builds the entire background manpage and cleaning command."
6196 (let ((command (concat pod2man-program " %s 2>/dev/null"))
6197 (flist Man-filter-list))
6198 (while (and flist (car flist))
6199 (let ((pcom (car (car flist)))
6200 (pargs (cdr (car flist))))
6201 (setq command
6202 (concat command " | " pcom " "
6203 (mapconcat '(lambda (phrase)
6204 (if (not (stringp phrase))
6205 (error "Malformed Man-filter-list"))
6206 phrase)
6207 pargs " ")))
6208 (setq flist (cdr flist))))
6209 command))
6141 6210
6142 (defun cperl-lazy-install ()) ; Avoid a warning 6211 (defun cperl-lazy-install ()) ; Avoid a warning
6143 6212
6144 (if (fboundp 'run-with-idle-timer) 6213 (if (fboundp 'run-with-idle-timer)
6145 (progn 6214 (progn