Allow bookmarks to be set from Gnus Article buffers (Bug #5975).
authorKatsumi Yamaoka <yamaoka@jpl.org>
Thu, 15 Jul 2010 00:11:32 +0000 (00:11 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Thu, 15 Jul 2010 00:11:32 +0000 (00:11 +0000)
2010-07-15  Katsumi Yamaoka  <yamaoka@jpl.org>
 * lpath.el: Bind bookmark-current-buffer, bookmark-yank-point for all
 Emacs versions; bind bookmark-make-record-function for Emacs >=22.

2010-07-13  Thierry Volpiatto  <thierry.volpiatto@gmail.com>
 Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
 Patch applied by Karl Fogel.

 * gnus-sum.el (gnus-summary-bookmark-make-record): Set
 `bookmark-yank-point' and `bookmark-current-buffer' to allow C-w.

2010-07-13  Thierry Volpiatto  <thierry.volpiatto@gmail.com>
 Allow bookmarks to be set from Gnus Article buffers (Bug #5975).
 Patch applied (with minor tweaks) by Karl Fogel.  Note this leaves
 C-w still not working correctly from Article buffers; Thierry's
 patch to fix that will be applied after this.

 * gnus-art.el (bookmark-make-record-function): New local variable.
 * gnus-sum.el (gnus-summary-bookmark-make-record): Allow setting from
 article buffer.
 (gnus-summary-bookmark-jump): Maybe jump to article buffer.

2010-07-13  Karl Fogel  <kfogel@red-bean.com>
 * gnus-sum.el (bookmark-make-record-default): Adjust declaration, based
 on changes in bookmark.el.

lisp/ChangeLog
lisp/gnus-art.el
lisp/gnus-sum.el
lisp/lpath.el

index faa0f1a..c6c93ab 100644 (file)
@@ -1,3 +1,34 @@
+2010-07-15  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+       * lpath.el: Bind bookmark-current-buffer, bookmark-yank-point for all
+       Emacs versions; bind bookmark-make-record-function for Emacs >=22.
+
+2010-07-13  Thierry Volpiatto  <thierry.volpiatto@gmail.com>
+
+       Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
+       Patch applied by Karl Fogel.
+
+       * gnus-sum.el (gnus-summary-bookmark-make-record): Set
+       `bookmark-yank-point' and `bookmark-current-buffer' to allow C-w.
+
+2010-07-13  Thierry Volpiatto  <thierry.volpiatto@gmail.com>
+
+       Allow bookmarks to be set from Gnus Article buffers (Bug #5975).
+       Patch applied (with minor tweaks) by Karl Fogel.  Note this leaves
+       C-w still not working correctly from Article buffers; Thierry's
+       patch to fix that will be applied after this.
+
+       * gnus-art.el (bookmark-make-record-function): New local variable.
+
+       * gnus-sum.el (gnus-summary-bookmark-make-record): Allow setting from
+       article buffer.
+       (gnus-summary-bookmark-jump): Maybe jump to article buffer.
+
+2010-07-13  Karl Fogel  <kfogel@red-bean.com>
+
+       * gnus-sum.el (bookmark-make-record-default): Adjust declaration, based
+       on changes in bookmark.el.
+
 2010-07-13  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * gnus-xmas.el (gnus-xmas-read-event-char): Use display-message with
index 6b20fa6..51be451 100644 (file)
@@ -4452,6 +4452,8 @@ commands:
   (make-local-variable 'gnus-article-image-alist)
   (make-local-variable 'gnus-article-charset)
   (make-local-variable 'gnus-article-ignored-charsets)
+  (set (make-local-variable 'bookmark-make-record-function)
+       'gnus-summary-bookmark-make-record)
   ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
   ;; face.
   (set (make-local-variable 'nobreak-char-display) nil)
index 98a0556..0d35592 100644 (file)
@@ -12621,25 +12621,34 @@ If ALL is a number, fetch this number of articles."
     (gnus-summary-position-point)))
 
 ;;; Bookmark support for Gnus.
-(declare-function bookmark-make-record-default "bookmark" (&optional pos-only))
+(declare-function bookmark-make-record-default
+                  "bookmark" (&optional no-file no-context posn))
 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
 (declare-function bookmark-default-handler "bookmark" (bmk))
 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
 
 (defun gnus-summary-bookmark-make-record ()
   "Make a bookmark entry for a Gnus summary buffer."
-  (unless (and (derived-mode-p '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)
-      (location . ,(format "Gnus %s:%d:%s" grp art id))
-      (group . ,grp) (article . ,art)
-      (message-id . ,id) (handler . gnus-summary-bookmark-jump))))
+  (let (pos buf)
+    (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
+      (save-restriction              ; FIXME is it necessary to widen?
+        (widen) (setq pos (point))) ; Set position in gnus-article buffer.
+      (setq buf "art") ; We are recording bookmark from article buffer.
+      (setq bookmark-yank-point (point))
+      (setq bookmark-current-buffer (current-buffer))
+      (gnus-article-show-summary))      ; Go back in summary buffer.
+    ;; We are now recording bookmark from summary buffer.
+    (unless buf (setq buf "sum"))
+    (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 'no-file 'no-context pos)
+        (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
+        (group . ,grp) (article . ,art)
+        (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
 
 ;;;###autoload
 (defun gnus-summary-bookmark-jump (bookmark)
@@ -12647,10 +12656,18 @@ If ALL is a number, fetch this number of articles."
 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)))
+        (id       (bookmark-prop-get bookmark 'message-id))
+        (buf      (car (split-string (bookmark-prop-get bookmark 'location)))))
     (gnus-fetch-group group (list article))
     (gnus-summary-insert-cached-articles)
     (gnus-summary-goto-article id nil 'force)
+    ;; FIXME we have to wait article buffer is ready (only large buffer)
+    ;; Is there a better solution to know that?
+    ;; If we don't wait `bookmark-default-handler' will have no chance
+    ;; to set position. However there is no error, just wrong pos.
+    (sit-for 1)
+    (when (string= buf "Gnus-art")
+      (other-window 1))
     (bookmark-default-handler
      `(""
        (buffer . ,(current-buffer))
index 2e08821..2cab505 100644 (file)
 
 (unless (featurep 'xemacs)
   (maybe-fbind '(pgg-display-output-buffer url-generic-parse-url))
-  (maybe-bind '(help-xref-stack-item
-               url-version w3-meta-charset-content-type-regexp
+  (maybe-bind '(bookmark-current-buffer
+               bookmark-yank-point help-xref-stack-item url-version
+               w3-meta-charset-content-type-regexp
                w3-meta-content-type-charset-regexp))
 
+  (when (>= emacs-major-version 22)
+    (maybe-bind '(bookmark-make-record-function)))
+
   (when (<= emacs-major-version 22)
     (defun ecomplete-add-item (type key text))
     (defun ecomplete-save nil)
      w3m-region window-edges))
   (maybe-bind
    '(adaptive-fill-first-line-regexp
-     buffer-display-table cursor-in-non-selected-windows
-     default-enable-multibyte-characters default-file-name-coding-system
-     eudc-protocol filladapt-mode gnus-agent-expire-current-dirs
-     help-xref-stack-item idna-program installation-directory
-     line-spacing mark-active mouse-selection-click-count
-     mouse-selection-click-count-buffer ps-print-color-p rmail-default-file
-     rmail-default-rmail-file rmail-insert-mime-forwarded-message-function
-     show-trailing-whitespace smtpmail-default-smtp-server
-     temporary-file-directory tool-bar-mode transient-mark-mode url-version
-     w3-meta-charset-content-type-regexp w3m-link-map
-     w3-meta-content-type-charset-regexp))
+     bookmark-current-buffer bookmark-yank-point buffer-display-table
+     cursor-in-non-selected-windows default-enable-multibyte-characters
+     default-file-name-coding-system eudc-protocol filladapt-mode
+     gnus-agent-expire-current-dirs help-xref-stack-item idna-program
+     installation-directory line-spacing mark-active
+     mouse-selection-click-count mouse-selection-click-count-buffer
+     ps-print-color-p rmail-default-file rmail-default-rmail-file
+     rmail-insert-mime-forwarded-message-function show-trailing-whitespace
+     smtpmail-default-smtp-server temporary-file-directory tool-bar-mode
+     transient-mark-mode url-version w3-meta-charset-content-type-regexp
+     w3m-link-map w3-meta-content-type-charset-regexp))
 
   (when (or (and (= emacs-major-version 21) (= emacs-minor-version 4))
            (featurep 'sxemacs))