emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r99881: Summary: Add bookmark support


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r99881: Summary: Add bookmark support for man, woman and gnus-summary.
Date: Mon, 12 Apr 2010 11:17:29 -0400
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 99881
author: Thierry Volpiatto <address@hidden>
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Mon 2010-04-12 11:17:29 -0400
message:
  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.
modified:
  lisp/ChangeLog
  lisp/gnus/ChangeLog
  lisp/gnus/gnus-sum.el
  lisp/man.el
  lisp/woman.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-04-10 23:54:50 +0000
+++ b/lisp/ChangeLog    2010-04-12 15:17:29 +0000
@@ -1,3 +1,13 @@
+2010-04-12  Thierry Volpiatto  <address@hidden>
+
+       * 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  <address@hidden>
 
        * 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  <address@hidden>
 

=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog       2010-04-03 01:54:24 +0000
+++ b/lisp/gnus/ChangeLog       2010-04-12 15:17:29 +0000
@@ -1,3 +1,9 @@
+2010-04-12  Thierry Volpiatto  <address@hidden>
+
+       * 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  <address@hidden>
 
        * mm-uu.el (mm-uu-pgp-signed-extract-1): Use buffer-file-coding-system

=== modified file 'lisp/gnus/gnus-sum.el'
--- a/lisp/gnus/gnus-sum.el     2010-03-23 07:37:09 +0000
+++ b/lisp/gnus/gnus-sum.el     2010-04-12 15:17:29 +0000
@@ -3072,6 +3072,9 @@
   (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 @@
          (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)

=== modified file 'lisp/man.el'
--- a/lisp/man.el       2010-03-05 20:18:20 +0000
+++ b/lisp/man.el       2010-04-12 15:17:29 +0000
@@ -221,6 +221,11 @@
   :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 @@
   (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 @@
                  (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)

=== modified file 'lisp/woman.el'
--- a/lisp/woman.el     2010-03-16 17:24:44 +0000
+++ b/lisp/woman.el     2010-04-12 15:17:29 +0000
@@ -1934,6 +1934,9 @@
        ;; `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 @@
                    (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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]