Perl6-Pugs
view release on metacpan or search on metacpan
util/cperl-mode.el view on Meta::CPAN
;;; By Anthony Foiani <afoiani@uswest.com>
;;; Getting help on modules in C-h f ?
;;; This is a modified version of `man'.
;;; Need to teach it how to lookup functions
;;;###autoload
(defun cperl-perldoc (word)
"Run `perldoc' on WORD."
(interactive
(list (let* ((default-entry (cperl-word-at-point))
(input (read-string
(format "perldoc entry%s: "
(if (string= default-entry "")
""
(format " (default %s)" default-entry))))))
(if (string= input "")
(if (string= default-entry "")
(error "No perldoc args given")
default-entry)
input))))
(require 'man)
(let* ((case-fold-search nil)
(is-func (and
(string-match "^[a-z]+$" word)
(string-match (concat "^" word "\\>")
(documentation-property
'cperl-short-docs
'variable-documentation))))
(manual-program (if is-func "perldoc -f" "perldoc")))
(cond
(cperl-xemacs-p
(let ((Manual-program "perldoc")
(Manual-switches (if is-func (list "-f"))))
(manual-entry word)))
(t
(Man-getpage-in-background word)))))
;;;###autoload
(defun cperl-perldoc-at-point ()
"Run a `perldoc' on the word around point."
(interactive)
(cperl-perldoc (cperl-word-at-point)))
(defcustom pod2man-program "pod2man"
"*File name for `pod2man'."
:type 'file
:group 'cperl)
;;; By Nick Roberts <Nick.Roberts@src.bae.co.uk> (with changes)
(defun cperl-pod-to-manpage ()
"Create a virtual manpage in Emacs from the Perl Online Documentation."
(interactive)
(require 'man)
(let* ((pod2man-args (concat buffer-file-name " | nroff -man "))
(bufname (concat "Man " buffer-file-name))
(buffer (generate-new-buffer bufname)))
(save-excursion
(set-buffer buffer)
(let ((process-environment (copy-sequence process-environment)))
;; Prevent any attempt to use display terminal fanciness.
(setenv "TERM" "dumb")
(set-process-sentinel
(start-process pod2man-program buffer "sh" "-c"
(format (cperl-pod2man-build-command) pod2man-args))
'Man-bgproc-sentinel)))))
;;; Updated version by him too
(defun cperl-build-manpage ()
"Create a virtual manpage in Emacs from the POD in the file."
(interactive)
(require 'man)
(cond
(cperl-xemacs-p
(let ((Manual-program "perldoc"))
(manual-entry buffer-file-name)))
(t
(let* ((manual-program "perldoc"))
(Man-getpage-in-background buffer-file-name)))))
(defun cperl-pod2man-build-command ()
"Builds the entire background manpage and cleaning command."
(let ((command (concat pod2man-program " %s 2>/dev/null"))
(flist (and (boundp 'Man-filter-list) Man-filter-list)))
(while (and flist (car flist))
(let ((pcom (car (car flist)))
(pargs (cdr (car flist))))
(setq command
(concat command " | " pcom " "
(mapconcat '(lambda (phrase)
(if (not (stringp phrase))
(error "Malformed Man-filter-list"))
phrase)
pargs " ")))
(setq flist (cdr flist))))
command))
(defun cperl-next-interpolated-REx-1 ()
"Move point to next REx which has interpolated parts without //o.
Skips RExes consisting of one interpolated variable.
Note that skipped RExen are not performance hits."
(interactive "")
(cperl-next-interpolated-REx 1))
(defun cperl-next-interpolated-REx-0 ()
"Move point to next REx which has interpolated parts without //o."
(interactive "")
(cperl-next-interpolated-REx 0))
(defun cperl-next-interpolated-REx (&optional skip beg limit)
"Move point to next REx which has interpolated parts.
SKIP is a list of possible types to skip, BEG and LIMIT are the starting
point and the limit of search (default to point and end of buffer).
SKIP may be a number, then it behaves as list of numbers up to SKIP; this
semantic may be used as a numeric argument.
Types are 0 for / $rex /o (interpolated once), 1 for /$rex/ (if $rex is
a result of qr//, this is not a performance hit), t for the rest."
(interactive "P")
( run in 0.462 second using v1.01-cache-2.11-cpan-6aa56a78535 )