From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.devel Subject: Re: No answer on bugs Date: Tue, 29 Jun 2010 21:57:08 +0200 Organization: ThierryVolpiatto Message-ID: <87iq51ehnv.fsf@tux.homenetwork> References: <87y6dydn6q.fsf@tux.homenetwork> <87d3va9c5u.fsf@red-bean.com> <201006292126.15409.tassilo@member.fsf.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1277841625 16782 80.91.229.12 (29 Jun 2010 20:00:25 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 29 Jun 2010 20:00:25 +0000 (UTC) Cc: Karl Fogel , emacs-devel@gnu.org To: Tassilo Horn Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 29 22:00:23 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OTgyj-0000v6-7I for ged-emacs-devel@m.gmane.org; Tue, 29 Jun 2010 22:00:21 +0200 Original-Received: from localhost ([127.0.0.1]:38351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTgyi-0004Zy-Jb for ged-emacs-devel@m.gmane.org; Tue, 29 Jun 2010 16:00:20 -0400 Original-Received: from [140.186.70.92] (port=37404 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTgya-0004Zj-H8 for emacs-devel@gnu.org; Tue, 29 Jun 2010 16:00:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OTgyZ-000549-0H for emacs-devel@gnu.org; Tue, 29 Jun 2010 16:00:12 -0400 Original-Received: from mail-wy0-f169.google.com ([74.125.82.169]:36740) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OTgyY-000542-Lf for emacs-devel@gnu.org; Tue, 29 Jun 2010 16:00:10 -0400 Original-Received: by wyb39 with SMTP id 39so8726wyb.0 for ; Tue, 29 Jun 2010 13:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject :organization:references:date:in-reply-to:message-id:user-agent :mime-version:content-type; bh=RIEH6oY5oi6gUhL0z+HCcv7RSgtzs/XWVW5HqO4Apb0=; b=UdFae4mY9JutHZGDrXzPqDmVoC4LO61rbb/Lf/6zWYiphNVa57Ut3k1JPPybMP+IJn Wi3EgECEf/tu++4sf9Ux0G2r+8TJC7dybDzXwIWJ4vSIAmC18XWVP9LeOevGwTGDW7Xm 6b2l7wYQGAGKC8fLd0BP+gFrm9Fkpk8ntyj1A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:organization:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; b=ZaiwQ4bTTJ9g0+Ksj5hKpV+J44WAvNV0lhSXcrUUbzpnVgfHTCpExXt9ylMgP/Zaop 4ir5sRrnhRW8AGlKlayUAFDW7u6YCHwBuzIASjFe2sJrt6z/8L4nm1kRirbD7fqtEPtO 73Zm2dR21iiYzY/MpfflVJvX0owAfR3lm0NPs= Original-Received: by 10.216.85.17 with SMTP id t17mr5701501wee.30.1277841609130; Tue, 29 Jun 2010 13:00:09 -0700 (PDT) Original-Received: from tux.homenetwork (33.77.197-77.rev.gaoland.net [77.197.77.33]) by mx.google.com with ESMTPS id o72sm6814131wej.39.2010.06.29.13.00.06 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 29 Jun 2010 13:00:07 -0700 (PDT) In-Reply-To: <201006292126.15409.tassilo@member.fsf.org> (Tassilo Horn's message of "Tue, 29 Jun 2010 21:26:14 +0200") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:126512 Archived-At: --=-=-= Tassilo Horn writes: > On Tuesday 29 June 2010 15:54:53 Karl Fogel wrote: > > Hi! > >> Thierry Volpiatto writes: >> >- bug#5975: 24.0.50; [PATCH]Feature request: bookmarking from gnus article >> > buffer >> > >> >No one answer, not fixed. >> >> I'll take a look at this. > > Karl, you might want to have a look at org-gnus.el, which provides > linking support to gnus articles and groups for org-mode. Maybe you can > either borrow some code from me or even better, use those few functions. FYI bookmarking from gnus(summary) is now provided in Emacs(24). What is missing is bookmarking from gnus-article buffer. The patch i propose apply on my precedent work. If you want to reuse org code, you will have much more work to enable it for bookmark (rewrite all), as the things are differents. I attach here my patch again. -- Thierry Volpiatto Gpg key: http://pgp.mit.edu/ --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=patch-109087.patch # HG changeset patch # User Thierry Volpiatto # Date 1277840529 -7200 # Node ID dc2c984058cf101132a55fcf22bf85e173f6482e # Parent 20190537be1cd79ad83375df1f70ff0ec3dc60fd Allow to bookmark a mail from a Gnus article buffer and retrieve position. * lisp/bookmark.el (bookmark-make-record-default) Avoid recording *-context-string when not needed. * lisp/gnus/gnus-art.el set `bookmark-make-record-function' local. * lisp/gnus/gnus-sum.el (gnus-summary-bookmark-make-record) allow recording from article buffer. (gnus-summary-bookmark-jump) maybe jump to article buffer. diff --git a/lisp/bookmark.el b/lisp/bookmark.el --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -528,26 +528,30 @@ (setq bookmark-current-bookmark stripped-name) (bookmark-bmenu-surreptitiously-rebuild-list))) -(defun bookmark-make-record-default (&optional point-only) +(defun bookmark-make-record-default (&optional point-only pos read-only) "Return the record describing the location of a new bookmark. Must be at the correct position in the buffer in which the bookmark is being set. If POINT-ONLY is non-nil, then only return the subset of the -record that pertains to the location within the buffer." +record that pertains to the location within the buffer. +If READ-ONLY is non-nil that's mean buffer is read-only and +there is no need to record front/rear-context-string, position is enough." `(,@(unless point-only `((filename . ,(bookmark-buffer-file-name)))) - (front-context-string - . ,(if (>= (- (point-max) (point)) bookmark-search-size) - (buffer-substring-no-properties - (point) - (+ (point) bookmark-search-size)) - nil)) - (rear-context-string - . ,(if (>= (- (point) (point-min)) bookmark-search-size) - (buffer-substring-no-properties - (point) - (- (point) bookmark-search-size)) - nil)) - (position . ,(point)))) + ,@(unless read-only `((front-context-string + . ,(if (>= (- (point-max) (point)) + bookmark-search-size) + (buffer-substring-no-properties + (point) + (+ (point) bookmark-search-size)) + nil)))) + ,@(unless read-only `((rear-context-string + . ,(if (>= (- (point) (point-min)) + bookmark-search-size) + (buffer-substring-no-properties + (point) + (- (point) bookmark-search-size)) + nil)))) + (position . ,(or pos (point))))) ;;; File format stuff diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -4452,6 +4452,8 @@ (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) diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -12628,18 +12628,24 @@ (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. + (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 'point-only pos 'read-only) + (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 +12653,18 @@ 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)) --=-=-=--