Gnus development mailing list
 help / color / mirror / Atom feed
* [Patch] Sticky Article Buffers
@ 2007-07-04 22:27 Tassilo Horn
  2007-07-05  6:38 ` Didier Verna
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Tassilo Horn @ 2007-07-04 22:27 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 501 bytes --]

Hello,

this patch implements sticky article buffers. With `C-c s' in Summary
Buffer you open an article buffer and make it sticky. Sticky means that
it won't be killed when selecting another article or leaving the
summary.

This might me useful if you write an article and have to quote many
other articles (which you would make sticky first, instead of visiting
them via summary over and over again).

You kill a sticky article buffer with `q' in it or with
`gnus-kill-all-sticky-article-buffers'.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Sticky Article Buffers --]
[-- Type: text/x-patch, Size: 7056 bytes --]

Index: gnus.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus.el,v
retrieving revision 7.66
diff -u -r7.66 gnus.el
--- gnus.el	4 Jun 2007 11:58:52 -0000	7.66
+++ gnus.el	4 Jul 2007 22:21:17 -0000
@@ -909,6 +909,18 @@
 	(setcdr buffers (cddr buffers)))))
   gnus-buffers)
 
+(defun gnus-kill-all-sticky-article-buffers (confirm)
+  "Kills all sticky article buffers. If a prefix arg is given,
+it'll ask for confirmation."
+  (interactive "P")
+  (dolist (buf (gnus-buffers))
+    (with-current-buffer buf
+      (when (eq major-mode 'gnus-sticky-article-mode)
+	(if (not confirm)
+	    (gnus-kill-buffer buf)
+	  (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf)))
+	    (gnus-kill-buffer buf)))))))
+
 ;;; Splash screen.
 
 (defvar gnus-group-buffer "*Group*")
@@ -4358,6 +4370,12 @@
 (gnus-ems-redefine)
 
 (provide 'gnus)
+
+;; Local Variables:
+;; coding: iso-8859-1
+;; indent-tabs-mode: t
+;; tab-width: 8
+;; End:
 
 ;;; arch-tag: acebeeab-f331-4f8f-a7ea-89c58c84f636
 ;;; gnus.el ends here
Index: gnus-sum.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-sum.el,v
retrieving revision 7.188
diff -u -r7.188 gnus-sum.el
--- gnus-sum.el	14 Jun 2007 09:49:28 -0000	7.188
+++ gnus-sum.el	4 Jul 2007 22:21:37 -0000
@@ -1768,6 +1768,7 @@
   "j" gnus-summary-goto-article
   "^" gnus-summary-refer-parent-article
   "\M-^" gnus-summary-refer-article
+  "\C-cs" gnus-summary-make-sticky-article
   "u" gnus-summary-tick-article-forward
   "!" gnus-summary-tick-article-forward
   "U" gnus-summary-tick-article-backward
@@ -2444,6 +2445,7 @@
 	      ["Remove article" gnus-cache-remove-article t])
 	     ["Translate" gnus-article-babel t]
 	     ["Select article buffer" gnus-summary-select-article-buffer t]
+	     ["Make article buffer sticky" gnus-summary-make-sticky-article t]
 	     ["Enter digest buffer" gnus-summary-enter-digest-group t]
 	     ["Isearch article..." gnus-summary-isearch-article t]
 	     ["Beginning of the article" gnus-summary-beginning-of-article t]
@@ -6937,9 +6939,13 @@
     (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
     ;; If we have several article buffers, we kill them at exit.
     (unless gnus-single-article-buffer
-      (gnus-kill-buffer gnus-article-buffer)
-      (gnus-kill-buffer gnus-original-article-buffer)
-      (setq gnus-article-current nil))
+      (when (gnus-buffer-live-p gnus-article-buffer)
+	(with-current-buffer gnus-article-buffer
+	  ;; Don't kill sticky article buffers
+	  (unless (eq major-mode 'gnus-sticky-article-mode)
+	    (gnus-kill-buffer gnus-article-buffer)
+	    (setq gnus-article-current nil))))
+      (gnus-kill-buffer gnus-original-article-buffer))
     (when gnus-use-cache
       (gnus-cache-possibly-remove-articles)
       (gnus-cache-save-buffers))
@@ -6973,9 +6979,13 @@
 	nil				;Nothing to do.
       ;; If we have several article buffers, we kill them at exit.
       (unless gnus-single-article-buffer
-	(gnus-kill-buffer gnus-article-buffer)
-	(gnus-kill-buffer gnus-original-article-buffer)
-	(setq gnus-article-current nil))
+	(when (gnus-buffer-live-p gnus-article-buffer)
+	  (with-current-buffer gnus-article-buffer
+	    ;; Don't kill sticky article buffers
+	    (unless (eq major-mode 'gnus-sticky-article-mode)
+	      (gnus-kill-buffer gnus-article-buffer)
+	      (setq gnus-article-current nil))))
+	(gnus-kill-buffer gnus-original-article-buffer))
       (set-buffer buf)
       (if (not gnus-kill-summary-on-exit)
 	  (progn
@@ -7908,6 +7918,48 @@
       (error "Article history empty")))
   (gnus-summary-position-point))
 
+(defun gnus-summary-make-sticky-article (arg)
+  "Make the current article sticky. If a prefix arg is given you
+will be asked for a name for this sticky buffer."
+  (interactive "P")
+  (gnus-configure-windows 'article)
+  (gnus-summary-show-thread)
+  (gnus-summary-select-article nil nil 'pseudo)
+  (let (new-art-buf-name)
+    (gnus-eval-in-buffer-window gnus-article-buffer
+      (setq new-art-buf-name
+            (rename-buffer
+             (concat
+              "*Sticky Article: "
+              (if arg
+                  (read-from-minibuffer "Sticky article buffer name: ")
+                (gnus-with-article-headers
+                  (gnus-article-goto-header "subject")
+                  (setq new-art-buf-name
+                        (buffer-substring-no-properties
+                         (line-beginning-position) (line-end-position)))
+                  (goto-char (point-min))
+                  (gnus-article-goto-header "from")
+                  (setq new-art-buf-name
+                        (concat
+                         new-art-buf-name ", "
+                         (buffer-substring-no-properties
+                          (line-beginning-position) (line-end-position))))
+                  (goto-char (point-min))
+                  (gnus-article-goto-header "date")
+                  (setq new-art-buf-name
+                        (concat
+                         new-art-buf-name ", "
+                         (buffer-substring-no-properties
+                          (line-beginning-position) (line-end-position))))))
+              "*")
+             t)))
+    (setq gnus-article-buffer new-art-buf-name))
+  (gnus-summary-recenter)
+  (gnus-summary-position-point)
+  (set-buffer gnus-article-buffer)
+  (gnus-sticky-article-mode))
+
 ;; Summary commands and functions for limiting the summary buffer.
 
 (defun gnus-summary-limit-to-articles (n)
@@ -12404,6 +12456,8 @@
 
 ;; Local Variables:
 ;; coding: iso-8859-1
+;; indent-tabs-mode: t
+;; tab-width: 8
 ;; End:
 
 ;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
Index: gnus-art.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-art.el,v
retrieving revision 7.219
diff -u -r7.219 gnus-art.el
--- gnus-art.el	26 Jun 2007 07:31:41 -0000	7.219
+++ gnus-art.el	4 Jul 2007 22:21:50 -0000
@@ -4365,6 +4365,26 @@
     (gnus-run-hooks 'gnus-article-prepare-hook)))
 
 ;;;
+;;; Gnus Sticky Article Mode
+;;;
+
+(define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
+  "Mode for sticky articles.")
+
+(define-key gnus-sticky-article-mode-map "q" 'gnus-sticky-article-kill-buffer)
+
+(defun gnus-sticky-article-kill-buffer (&optional buffer)
+  "Kills the given sticky article buffer. If none is given, it'll
+assume the current buffer and kill it if it has
+`gnus-sticky-article-mode'."
+  (interactive)
+  (unless buffer
+    (setq buffer (current-buffer)))
+  (with-current-buffer buffer
+    (when (eq major-mode 'gnus-sticky-article-mode)
+      (gnus-kill-buffer buffer))))
+
+;;;
 ;;; Gnus MIME viewing functions
 ;;;
 
@@ -8081,6 +8101,12 @@
 (provide 'gnus-art)
 
 (run-hooks 'gnus-art-load-hook)
+
+;; Local Variables:
+;; coding: iso-8859-1
+;; indent-tabs-mode: t
+;; tab-width: 8
+;; End:
 
 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
 ;;; gnus-art.el ends here

[-- Attachment #3: Type: text/plain, Size: 206 bytes --]


I tested it briefly and it seems to do what it should. Anyway, it's my
first non-trivial patch, so feel free to comment.

Bye,
Tassilo
-- 
      "DRM manages rights in the same way a jail manages freedom"

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch] Sticky Article Buffers
  2007-07-04 22:27 [Patch] Sticky Article Buffers Tassilo Horn
@ 2007-07-05  6:38 ` Didier Verna
  2007-07-05  7:18   ` Tassilo Horn
  2007-07-05  8:29 ` Tassilo Horn
  2007-07-07 22:29 ` Tom Tromey
  2 siblings, 1 reply; 6+ messages in thread
From: Didier Verna @ 2007-07-05  6:38 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: ding

Tassilo Horn <tassilo@member.fsf.org> wrote:

> This might me useful if you write an article and have to quote many
> other articles (which you would make sticky first, instead of visiting
> them via summary over and over again).

[ I have not read the patch ]

This sounds interesting, but do you know that you can mark the articles
you want to quote, and then 'F' them, so that they appear all quoted in
your message ? This, of course, wouldn't work if you want to quote many
articles from different groups.

-- 
MySpace: http://www.myspace.com/didierverna

Didier Verna, didier@lrde.epita.fr, http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (1) 44 08 01 85
94276 Le Kremlin-Bicêtre, France   Fax.+33 (1) 53 14 59 22   didier@xemacs.org



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch] Sticky Article Buffers
  2007-07-05  6:38 ` Didier Verna
@ 2007-07-05  7:18   ` Tassilo Horn
  0 siblings, 0 replies; 6+ messages in thread
From: Tassilo Horn @ 2007-07-05  7:18 UTC (permalink / raw)
  To: ding

Didier Verna <didier@xemacs.org> writes:

Hi Didier,

> This sounds interesting, but do you know that you can mark the
> articles you want to quote, and then 'F' them, so that they appear all
> quoted in your message?

No, but that's also nice. :)

> This, of course, wouldn't work if you want to quote many articles from
> different groups.

Well, the quoting was just an example. There are other situation where
you want multiple article buffers easily accessible.

Bye,
Tassilo
-- 
The  desire  to  be  rewarded  for one's  creativity  does  not  justify
depriving  the world  in  general of  all  or part  of that  creativity.
(Richard M. Stallman)




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch] Sticky Article Buffers
  2007-07-04 22:27 [Patch] Sticky Article Buffers Tassilo Horn
  2007-07-05  6:38 ` Didier Verna
@ 2007-07-05  8:29 ` Tassilo Horn
  2007-07-07 22:29 ` Tom Tromey
  2 siblings, 0 replies; 6+ messages in thread
From: Tassilo Horn @ 2007-07-05  8:29 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 243 bytes --]

Hi all,

this new version removes some duplicate code in `gnus-summary-exit' and
removes those key bindings in `gnus-sticky-article-mode-map' that don't
work without a summary buffer.

And this diff is made from the top-leves gnus directory.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Sticky Article Buffers v2 --]
[-- Type: text/x-patch, Size: 7313 bytes --]

Index: lisp/gnus.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus.el,v
retrieving revision 7.66
diff -u -r7.66 gnus.el
--- lisp/gnus.el	4 Jun 2007 11:58:52 -0000	7.66
+++ lisp/gnus.el	5 Jul 2007 08:23:13 -0000
@@ -909,6 +909,18 @@
 	(setcdr buffers (cddr buffers)))))
   gnus-buffers)
 
+(defun gnus-kill-all-sticky-article-buffers (confirm)
+  "Kills all sticky article buffers. If a prefix arg is given,
+it'll ask for confirmation."
+  (interactive "P")
+  (dolist (buf (gnus-buffers))
+    (with-current-buffer buf
+      (when (eq major-mode 'gnus-sticky-article-mode)
+	(if (not confirm)
+	    (gnus-kill-buffer buf)
+	  (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf)))
+	    (gnus-kill-buffer buf)))))))
+
 ;;; Splash screen.
 
 (defvar gnus-group-buffer "*Group*")
@@ -4358,6 +4370,12 @@
 (gnus-ems-redefine)
 
 (provide 'gnus)
+
+;; Local Variables:
+;; coding: iso-8859-1
+;; indent-tabs-mode: t
+;; tab-width: 8
+;; End:
 
 ;;; arch-tag: acebeeab-f331-4f8f-a7ea-89c58c84f636
 ;;; gnus.el ends here
Index: lisp/gnus-sum.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-sum.el,v
retrieving revision 7.189
diff -u -r7.189 gnus-sum.el
--- lisp/gnus-sum.el	4 Jul 2007 09:21:13 -0000	7.189
+++ lisp/gnus-sum.el	5 Jul 2007 08:23:35 -0000
@@ -1768,6 +1768,7 @@
   "j" gnus-summary-goto-article
   "^" gnus-summary-refer-parent-article
   "\M-^" gnus-summary-refer-article
+  "\C-cs" gnus-summary-make-sticky-article
   "u" gnus-summary-tick-article-forward
   "!" gnus-summary-tick-article-forward
   "U" gnus-summary-tick-article-backward
@@ -2444,6 +2445,7 @@
 	      ["Remove article" gnus-cache-remove-article t])
 	     ["Translate" gnus-article-babel t]
 	     ["Select article buffer" gnus-summary-select-article-buffer t]
+	     ["Make article buffer sticky" gnus-summary-make-sticky-article t]
 	     ["Enter digest buffer" gnus-summary-enter-digest-group t]
 	     ["Isearch article..." gnus-summary-isearch-article t]
 	     ["Beginning of the article" gnus-summary-beginning-of-article t]
@@ -6937,9 +6939,13 @@
     (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
     ;; If we have several article buffers, we kill them at exit.
     (unless gnus-single-article-buffer
-      (gnus-kill-buffer gnus-article-buffer)
-      (gnus-kill-buffer gnus-original-article-buffer)
-      (setq gnus-article-current nil))
+      (when (gnus-buffer-live-p gnus-article-buffer)
+	(with-current-buffer gnus-article-buffer
+	  ;; Don't kill sticky article buffers
+	  (unless (eq major-mode 'gnus-sticky-article-mode)
+	    (gnus-kill-buffer gnus-article-buffer)
+	    (setq gnus-article-current nil))))
+      (gnus-kill-buffer gnus-original-article-buffer))
     (when gnus-use-cache
       (gnus-cache-possibly-remove-articles)
       (gnus-cache-save-buffers))
@@ -6971,11 +6977,6 @@
     (setq group-point (point))
     (if temporary
 	nil				;Nothing to do.
-      ;; If we have several article buffers, we kill them at exit.
-      (unless gnus-single-article-buffer
-	(gnus-kill-buffer gnus-article-buffer)
-	(gnus-kill-buffer gnus-original-article-buffer)
-	(setq gnus-article-current nil))
       (set-buffer buf)
       (if (not gnus-kill-summary-on-exit)
 	  (progn
@@ -7908,6 +7909,48 @@
       (error "Article history empty")))
   (gnus-summary-position-point))
 
+(defun gnus-summary-make-sticky-article (arg)
+  "Make the current article sticky. If a prefix arg is given you
+will be asked for a name for this sticky buffer."
+  (interactive "P")
+  (gnus-configure-windows 'article)
+  (gnus-summary-show-thread)
+  (gnus-summary-select-article nil nil 'pseudo)
+  (let (new-art-buf-name)
+    (gnus-eval-in-buffer-window gnus-article-buffer
+      (setq new-art-buf-name
+            (rename-buffer
+             (concat
+              "*Sticky Article: "
+              (if arg
+                  (read-from-minibuffer "Sticky article buffer name: ")
+                (gnus-with-article-headers
+                  (gnus-article-goto-header "subject")
+                  (setq new-art-buf-name
+                        (buffer-substring-no-properties
+                         (line-beginning-position) (line-end-position)))
+                  (goto-char (point-min))
+                  (gnus-article-goto-header "from")
+                  (setq new-art-buf-name
+                        (concat
+                         new-art-buf-name ", "
+                         (buffer-substring-no-properties
+                          (line-beginning-position) (line-end-position))))
+                  (goto-char (point-min))
+                  (gnus-article-goto-header "date")
+                  (setq new-art-buf-name
+                        (concat
+                         new-art-buf-name ", "
+                         (buffer-substring-no-properties
+                          (line-beginning-position) (line-end-position))))))
+              "*")
+             t)))
+    (setq gnus-article-buffer new-art-buf-name))
+  (gnus-summary-recenter)
+  (gnus-summary-position-point)
+  (set-buffer gnus-article-buffer)
+  (gnus-sticky-article-mode))
+
 ;; Summary commands and functions for limiting the summary buffer.
 
 (defun gnus-summary-limit-to-articles (n)
@@ -12405,6 +12448,8 @@
 
 ;; Local Variables:
 ;; coding: iso-8859-1
+;; indent-tabs-mode: t
+;; tab-width: 8
 ;; End:
 
 ;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
Index: lisp/gnus-art.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-art.el,v
retrieving revision 7.219
diff -u -r7.219 gnus-art.el
--- lisp/gnus-art.el	26 Jun 2007 07:31:41 -0000	7.219
+++ lisp/gnus-art.el	5 Jul 2007 08:23:48 -0000
@@ -4365,6 +4365,35 @@
     (gnus-run-hooks 'gnus-article-prepare-hook)))
 
 ;;;
+;;; Gnus Sticky Article Mode
+;;;
+
+(define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
+  "Mode for sticky articles."
+  ;; Release bindings that won't work.
+  (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
+			     gnus-sticky-article-mode-map)
+  (substitute-key-definition 'gnus-article-refer-article 'undefined
+			     gnus-sticky-article-mode-map)
+  (dolist (k '("e" "h" "s" "F" "R"))
+    (define-key gnus-sticky-article-mode-map k nil))
+  (define-key gnus-sticky-article-mode-map "q" 'gnus-sticky-article-kill-buffer)
+  (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
+  (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
+
+
+(defun gnus-sticky-article-kill-buffer (&optional buffer)
+  "Kills the given sticky article buffer. If none is given, it'll
+assume the current buffer and kill it if it has
+`gnus-sticky-article-mode'."
+  (interactive)
+  (unless buffer
+    (setq buffer (current-buffer)))
+  (with-current-buffer buffer
+    (when (eq major-mode 'gnus-sticky-article-mode)
+      (gnus-kill-buffer buffer))))
+
+;;;
 ;;; Gnus MIME viewing functions
 ;;;
 
@@ -8081,6 +8110,12 @@
 (provide 'gnus-art)
 
 (run-hooks 'gnus-art-load-hook)
+
+;; Local Variables:
+;; coding: iso-8859-1
+;; indent-tabs-mode: t
+;; tab-width: 8
+;; End:
 
 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
 ;;; gnus-art.el ends here

[-- Attachment #3: Type: text/plain, Size: 137 bytes --]


Bye,
Tassilo
-- 
          "Emacs is not a development tool but a way of life."
                - David Kastrup in alt.religion.emacs -

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch] Sticky Article Buffers
  2007-07-04 22:27 [Patch] Sticky Article Buffers Tassilo Horn
  2007-07-05  6:38 ` Didier Verna
  2007-07-05  8:29 ` Tassilo Horn
@ 2007-07-07 22:29 ` Tom Tromey
  2007-07-08 10:56   ` Tassilo Horn
  2 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2007-07-07 22:29 UTC (permalink / raw)
  To: ding

>>>>> "Tassilo" == Tassilo Horn <tassilo@member.fsf.org> writes:

Tassilo> this patch implements sticky article buffers. With `C-c s' in
Tassilo> Summary Buffer you open an article buffer and make it
Tassilo> sticky.

AIUI, `C-c LETTER' is reserved for user key bindings.
See info node "elisp (Key Binding Conventions)".

Tom




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch] Sticky Article Buffers
  2007-07-07 22:29 ` Tom Tromey
@ 2007-07-08 10:56   ` Tassilo Horn
  0 siblings, 0 replies; 6+ messages in thread
From: Tassilo Horn @ 2007-07-08 10:56 UTC (permalink / raw)
  To: ding

Tom Tromey <tromey@redhat.com> writes:

Hi Tom,

> AIUI, `C-c LETTER' is reserved for user key bindings.  See info node
> "elisp (Key Binding Conventions)".

I know and I'll change it. Do you have a suggestion what might be a good
free key?

Bye,
Tassilo
-- 
Programming today is a race between software engineers striving to build
   bigger and better idiot-proof programs, and the Universe trying to
   produce bigger and better idiots. So far, the Universe is winning.




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-07-08 10:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-04 22:27 [Patch] Sticky Article Buffers Tassilo Horn
2007-07-05  6:38 ` Didier Verna
2007-07-05  7:18   ` Tassilo Horn
2007-07-05  8:29 ` Tassilo Horn
2007-07-07 22:29 ` Tom Tromey
2007-07-08 10:56   ` Tassilo Horn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).