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

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).