summaryrefslogtreecommitdiff
path: root/lisp/man.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2010-04-12 11:17:29 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2010-04-12 11:17:29 -0400
commit45be326afc57551050f71b07cb40752a8dfa2aa3 (patch)
treeb00795acf1ffb50b5e8730a8c111bdd7e962961b /lisp/man.el
parent4794a58232a4a31d628ac6a145dd1113c0ade6fd (diff)
downloademacs-45be326afc57551050f71b07cb40752a8dfa2aa3.tar.gz
Summary: Add bookmark support for man, woman and gnus-summary.
* woman.el (woman-bookmark-make-record, woman-bookmark-jump): New functions. (woman-mode): Setup bookmark support. * man.el (man-set-default-bookmark-title, man-bookmark-make-record) (man-bookmark-jump): New functions. (Man-mode): Setup bookmark support. * gnus-sum.el (gnus-summary-bookmark-make-record) (gnus-summary-bookmark-jump): New functions. (gnus-summary-mode): Setup bookmark support.
Diffstat (limited to 'lisp/man.el')
-rw-r--r--lisp/man.el46
1 files changed, 46 insertions, 0 deletions
diff --git a/lisp/man.el b/lisp/man.el
index 8eb5f73e245..0402c08522d 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -221,6 +221,11 @@ the associated section number."
:type '(repeat string)
:group 'man)
+(defcustom Man-name-local-regexp "^NOM$"
+ "*The translation of the uppercase word NAME in your language.
+Used in `bookmark-set' to get the default bookmark name."
+ :type 'string :group 'bookmark)
+
(defvar manual-program "man"
"The name of the program that produces man pages.")
@@ -1325,6 +1330,9 @@ The following key bindings are currently in effect in the buffer:
(setq imenu-generic-expression (list (list nil Man-heading-regexp 0)))
(set (make-local-variable 'outline-regexp) Man-heading-regexp)
(set (make-local-variable 'outline-level) (lambda () 1))
+ ;; Bookmark support.
+ (set (make-local-variable 'bookmark-make-record-function)
+ 'man-bookmark-make-record)
(Man-build-page-list)
(Man-strip-page-headers)
(Man-unindent)
@@ -1659,6 +1667,44 @@ Specify which REFERENCE to use; default is based on word at point."
(setq path nil))
(setq complete-path nil)))
complete-path))
+
+;;; Bookmark Man Support
+
+(defun man-set-default-bookmark-title ()
+ "Set default bookmark title for Man or woman page based \
+on NAME or `Man-name-local-regexp' entry."
+ (save-excursion
+ (goto-char (point-min))
+ (when (or (re-search-forward Man-name-local-regexp nil t)
+ (re-search-forward "^NAME$" nil t))
+ (forward-line 1)
+ (unless (> (skip-chars-forward " ") 0)
+ (skip-chars-forward "\t"))
+ (buffer-substring-no-properties (point) (line-end-position)))))
+
+(defun man-bookmark-make-record ()
+ "Make a bookmark entry for a Man buffer."
+ `(,(man-set-default-bookmark-title)
+ ,@(bookmark-make-record-default 'point-only)
+ (buffer-name . ,(buffer-name (current-buffer)))
+ (handler . man-bookmark-jump)))
+
+(defun man-bookmark-jump (bookmark)
+ "Default bookmark handler for Man buffers."
+ (let* ((buf (bookmark-prop-get bookmark 'buffer-name))
+ (buf-lst (split-string buf))
+ (node (replace-regexp-in-string "\*" "" (car (last buf-lst))))
+ (ind (when (> (length buf-lst) 2) (second buf-lst)))
+ (Man-notify-method (case bookmark-jump-display-function
+ ('switch-to-buffer 'pushy)
+ ('switch-to-buffer-other-window 'friendly)
+ ('display-buffer 'quiet)
+ (t 'friendly))))
+ (man (if ind (format "%s(%s)" node ind) node))
+ (while (get-process "man") (sit-for 1))
+ (bookmark-default-handler
+ `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bookmark)))))
+
;; Init the man package variables, if not already done.
(Man-init-defvars)