From 45be326afc57551050f71b07cb40752a8dfa2aa3 Mon Sep 17 00:00:00 2001 From: Thierry Volpiatto Date: Mon, 12 Apr 2010 11:17:29 -0400 Subject: [PATCH] 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. --- lisp/ChangeLog | 33 +++++++++++++++++++++------------ lisp/gnus/ChangeLog | 6 ++++++ lisp/gnus/gnus-sum.el | 35 +++++++++++++++++++++++++++++++++++ lisp/man.el | 46 ++++++++++++++++++++++++++++++++++++++++++++++ lisp/woman.el | 21 +++++++++++++++++++++ 5 files changed, 129 insertions(+), 12 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8bf9dcd4607..545ce63780f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2010-04-12 Thierry Volpiatto + + * 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. + 2010-04-10 Jari Aalto * comint.el (comint-password-prompt-regexp): Use regexp-opt, and @@ -13,10 +23,9 @@ * net/tramp.el (tramp-completion-function-alist) (tramp-file-name-regexp, tramp-chunksize) - (tramp-local-coding-commands, tramp-remote-coding-commands): Fix - docstring. - (tramp-remote-process-environment): Use `format' instead of - `concat'. + (tramp-local-coding-commands, tramp-remote-coding-commands): + Fix docstring. + (tramp-remote-process-environment): Use `format' instead of `concat'. (tramp-handle-directory-files-and-attributes) (tramp-get-remote-path): Use `copy-tree'. (tramp-handle-file-name-all-completions): Backward/ XEmacs @@ -24,11 +33,11 @@ `read-file-name-completion-ignore-case' does not exist. (tramp-do-copy-or-rename-file-directly): Do not use `tramp-handle-file-remote-p'. - (tramp-do-copy-or-rename-file-out-of-band): Use - `tramp-compat-delete-directory'. + (tramp-do-copy-or-rename-file-out-of-band): + Use `tramp-compat-delete-directory'. (tramp-do-copy-or-rename-file-out-of-band) - (tramp-compute-multi-hops, tramp-maybe-open-connection): Use - `format-spec-make'. + (tramp-compute-multi-hops, tramp-maybe-open-connection): + Use `format-spec-make'. (tramp-find-foreign-file-name-handler) (tramp-advice-make-auto-save-file-name) (tramp-set-auto-save-file-modes): Remove superfluous check for @@ -38,8 +47,8 @@ (tramp-check-for-regexp): Use (forward-line 1). (tramp-set-auto-save-file-modes): Adapt version check. - * net/tramp-compat.el (tramp-advice-file-expand-wildcards): Wrap - call of `featurep' for 2nd argument. + * net/tramp-compat.el (tramp-advice-file-expand-wildcards): + Wrap call of `featurep' for 2nd argument. (tramp-compat-make-temp-file): Simplify fallback implementation. (tramp-compat-copy-tree): Remove function. (tramp-compat-delete-directory): Provide implementation for older @@ -69,8 +78,8 @@ Add --author support to git commit. * vc-git.el (vc-git-checkin): Pass extra-args to the commit command. (vc-git-log-edit-mode): New minor mode. - (log-edit-mode, log-edit-extra-flags, log-edit-mode): New - declarations. + (log-edit-mode, log-edit-extra-flags, log-edit-mode): + New declarations. 2010-04-09 Eric Raymond diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index e418c5f9f5a..47cf6997d60 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,3 +1,9 @@ +2010-04-12 Thierry Volpiatto + + * gnus-sum.el (gnus-summary-bookmark-make-record) + (gnus-summary-bookmark-jump): New functions. + (gnus-summary-mode): Setup bookmark support. + 2010-04-01 Andreas Schwab * mm-uu.el (mm-uu-pgp-signed-extract-1): Use buffer-file-coding-system diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index 608224e436d..a8e612856a0 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -3072,6 +3072,9 @@ The following commands are available: (gnus-run-mode-hooks 'gnus-summary-mode-hook) (turn-on-gnus-mailing-list-mode) (mm-enable-multibyte) + ;; Bookmark support. + (set (make-local-variable 'bookmark-make-record-function) + 'gnus-summary-bookmark-make-record) (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy) (gnus-update-summary-mark-positions)) @@ -12640,6 +12643,38 @@ If ALL is a number, fetch this number of articles." (gnus-summary-limit (gnus-sorted-nunion old new)))) (gnus-summary-position-point))) +;;; BOOKMARK support for GNUS. + +(defun gnus-summary-bookmark-make-record () + "Make a bookmark entry for a Gnus buffer." + (require 'gnus) + (unless (and (eq major-mode 'gnus-summary-mode) gnus-article-current) + (error "Please retry from the Gnus summary buffer")) ;[1] + (let* ((subject (elt (gnus-summary-article-header) 1)) + (grp (car gnus-article-current)) + (art (cdr gnus-article-current)) + (head (gnus-summary-article-header art)) + (id (mail-header-id head))) + `(,subject + ,@(bookmark-make-record-default 'point-only) + (group . ,grp) (article . ,art) + (message-id . ,id) (handler . gnus-summary-bookmark-jump)))) + + +(defun gnus-summary-bookmark-jump (bookmark) + "Handler function for record returned by `gnus-summary-bookmark-make-record'. +BOOKMARK is a bookmark name or a bookmark record." + (let ((group (bookmark-prop-get bookmark 'group)) + (article (bookmark-prop-get bookmark 'article)) + (id (bookmark-prop-get bookmark 'message-id)) + buf) + (gnus-fetch-group group (list article)) + (gnus-summary-insert-cached-articles) + (gnus-summary-goto-article id nil 'force) + (setq buf (current-buffer)) + (bookmark-default-handler + `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bookmark))))) + (gnus-summary-make-all-marking-commands) (gnus-ems-redefine) 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) diff --git a/lisp/woman.el b/lisp/woman.el index 79d6d84aff1..97d65e422de 100644 --- a/lisp/woman.el +++ b/lisp/woman.el @@ -1934,6 +1934,9 @@ See `Man-mode' for additional details." ;; `make-local-variable' in case imenu not yet loaded! woman-imenu-generic-expression) (set (make-local-variable 'imenu-space-replacement) " ") + ;; Bookmark support. + (set (make-local-variable 'bookmark-make-record-function) + 'woman-bookmark-make-record) ;; For reformat ... ;; necessary when reformatting a file in its old buffer: (setq imenu--last-menubar-index-alist nil) @@ -4516,6 +4519,24 @@ logging the message." (recenter 0)))))))) nil) ; for woman-file-readable-p etc. +;;; Bookmark Woman support. + +(defun woman-bookmark-make-record () + "Make a bookmark entry for a Woman buffer." + `(,(man-set-default-bookmark-title) + ,@(bookmark-make-record-default 'point-only) + (filename . ,woman-last-file-name) + (handler . woman-bookmark-jump))) + + +(defun woman-bookmark-jump (bookmark) + "Default bookmark handler for Woman buffers." + (let* ((file (bookmark-prop-get bookmark 'filename)) + (buf (save-window-excursion + (woman-find-file file) (current-buffer)))) + (bookmark-default-handler + `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bookmark))))) + (provide 'woman) ;; arch-tag: eea35e90-552f-4712-a94b-d9ffd3db7651 -- 2.11.4.GIT