Mercurial > emacs
comparison lisp/gnus/gnus-sum.el @ 109396:8b1192833a1e
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.
* lisp/gnus/gnus-art.el (bookmark-make-record-function): New local variable.
* lisp/gnus/gnus-sum.el (gnus-summary-bookmark-make-record): Allow setting
from article buffer.
(gnus-summary-bookmark-jump): Maybe jump to article buffer.
author | Karl Fogel <kfogel@red-bean.com> |
---|---|
date | Wed, 14 Jul 2010 12:02:53 -0400 |
parents | fa4400531412 |
children | 4e6b8160da4b |
comparison
equal
deleted
inserted
replaced
109395:fa4400531412 | 109396:8b1192833a1e |
---|---|
12627 (declare-function bookmark-default-handler "bookmark" (bmk)) | 12627 (declare-function bookmark-default-handler "bookmark" (bmk)) |
12628 (declare-function bookmark-get-bookmark-record "bookmark" (bmk)) | 12628 (declare-function bookmark-get-bookmark-record "bookmark" (bmk)) |
12629 | 12629 |
12630 (defun gnus-summary-bookmark-make-record () | 12630 (defun gnus-summary-bookmark-make-record () |
12631 "Make a bookmark entry for a Gnus summary buffer." | 12631 "Make a bookmark entry for a Gnus summary buffer." |
12632 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current) | 12632 (let (pos buf) |
12633 (error "Please retry from the Gnus summary buffer")) ;[1] | 12633 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current) |
12634 (let* ((subject (elt (gnus-summary-article-header) 1)) | 12634 (save-restriction ; FIXME is it necessary to widen? |
12635 (grp (car gnus-article-current)) | 12635 (widen) (setq pos (point))) ; Set position in gnus-article buffer. |
12636 (art (cdr gnus-article-current)) | 12636 (setq buf "art") ; We are recording bookmark from article buffer. |
12637 (head (gnus-summary-article-header art)) | 12637 (gnus-article-show-summary)) ; Go back in summary buffer. |
12638 (id (mail-header-id head))) | 12638 ;; We are now recording bookmark from summary buffer. |
12639 `(,subject | 12639 (unless buf (setq buf "sum")) |
12640 ,@(bookmark-make-record-default 'point-only) | 12640 (let* ((subject (elt (gnus-summary-article-header) 1)) |
12641 (location . ,(format "Gnus %s:%d:%s" grp art id)) | 12641 (grp (car gnus-article-current)) |
12642 (group . ,grp) (article . ,art) | 12642 (art (cdr gnus-article-current)) |
12643 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))) | 12643 (head (gnus-summary-article-header art)) |
12644 (id (mail-header-id head))) | |
12645 `(,subject | |
12646 ,@(bookmark-make-record-default 'no-file 'no-context pos) | |
12647 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id)) | |
12648 (group . ,grp) (article . ,art) | |
12649 (message-id . ,id) (handler . gnus-summary-bookmark-jump))))) | |
12644 | 12650 |
12645 ;;;###autoload | 12651 ;;;###autoload |
12646 (defun gnus-summary-bookmark-jump (bookmark) | 12652 (defun gnus-summary-bookmark-jump (bookmark) |
12647 "Handler function for record returned by `gnus-summary-bookmark-make-record'. | 12653 "Handler function for record returned by `gnus-summary-bookmark-make-record'. |
12648 BOOKMARK is a bookmark name or a bookmark record." | 12654 BOOKMARK is a bookmark name or a bookmark record." |
12649 (let ((group (bookmark-prop-get bookmark 'group)) | 12655 (let ((group (bookmark-prop-get bookmark 'group)) |
12650 (article (bookmark-prop-get bookmark 'article)) | 12656 (article (bookmark-prop-get bookmark 'article)) |
12651 (id (bookmark-prop-get bookmark 'message-id))) | 12657 (id (bookmark-prop-get bookmark 'message-id)) |
12658 (buf (car (split-string (bookmark-prop-get bookmark 'location))))) | |
12652 (gnus-fetch-group group (list article)) | 12659 (gnus-fetch-group group (list article)) |
12653 (gnus-summary-insert-cached-articles) | 12660 (gnus-summary-insert-cached-articles) |
12654 (gnus-summary-goto-article id nil 'force) | 12661 (gnus-summary-goto-article id nil 'force) |
12662 ;; FIXME we have to wait article buffer is ready (only large buffer) | |
12663 ;; Is there a better solution to know that? | |
12664 ;; If we don't wait `bookmark-default-handler' will have no chance | |
12665 ;; to set position. However there is no error, just wrong pos. | |
12666 (sit-for 1) | |
12667 (when (string= buf "Gnus-art") | |
12668 (other-window 1)) | |
12655 (bookmark-default-handler | 12669 (bookmark-default-handler |
12656 `("" | 12670 `("" |
12657 (buffer . ,(current-buffer)) | 12671 (buffer . ,(current-buffer)) |
12658 . ,(bookmark-get-bookmark-record bookmark))))) | 12672 . ,(bookmark-get-bookmark-record bookmark))))) |
12659 | 12673 |