Gnus development mailing list
 help / color / mirror / Atom feed
From: Tassilo Horn <tassilo@member.fsf.org>
To: ding@gnus.org
Subject: Re: Sticky article buffers
Date: Wed, 25 Jul 2007 22:17:54 +0200	[thread overview]
Message-ID: <87ir888cgd.fsf@baldur.tsdh.de> (raw)
In-Reply-To: <v9wswo8h5i.fsf@marauder.physik.uni-ulm.de>

Hi,

here's a new patch. I did some renaming
(`gnus-sticky-article-kill-buffer' => `gnus-kill-sticky-article-buffer')
and moved that function to gnus.el.

The key to make an article sticky is now `A S' and "q" buries the
buffer -- "k" kills it.

The doc strings should be ok now, too.

I hope the patch works, I just killed the lines modifying file local
variables.

Bye,
Tassilo

--8<---------------cut here---------------start------------->8---
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	25 Jul 2007 20:07:42 -0000
@@ -909,6 +909,29 @@
 	(setcdr buffers (cddr buffers)))))
   gnus-buffers)
 
+(defun gnus-kill-sticky-article-buffer (&optional buffer)
+  "Kill the given sticky article BUFFER.
+If none is given, 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))))
+
+(defun gnus-kill-all-sticky-article-buffers (arg)
+  "Kill all sticky article buffers.
+If a prefix ARG is given, ask for confirmation."
+  (interactive "P")
+  (dolist (buf (gnus-buffers))
+    (with-current-buffer buf
+      (when (eq major-mode 'gnus-sticky-article-mode)
+	(if (not arg)
+	    (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*")
Index: lisp/gnus-art.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-art.el,v
retrieving revision 7.222
diff -u -r7.222 gnus-art.el
--- lisp/gnus-art.el	20 Jul 2007 11:30:50 -0000	7.222
+++ lisp/gnus-art.el	25 Jul 2007 20:07:55 -0000
@@ -4352,6 +4352,24 @@
     (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 "k" 'gnus-kill-sticky-article-buffer)
+  (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
+  (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
+  (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
+
+;;;
 ;;; Gnus MIME viewing functions
 ;;;
 
Index: lisp/gnus-sum.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-sum.el,v
retrieving revision 7.191
diff -u -r7.191 gnus-sum.el
--- lisp/gnus-sum.el	23 Jul 2007 23:44:36 -0000	7.191
+++ lisp/gnus-sum.el	25 Jul 2007 20:08:17 -0000
@@ -1997,6 +1997,7 @@
   "g" gnus-summary-show-article
   "s" gnus-summary-isearch-article
   "P" gnus-summary-print-article
+  "S" gnus-summary-make-sticky-article
   "M" gnus-mailing-list-insinuate
   "t" gnus-article-babel)
 
@@ -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,49 @@
       (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, ask for a name for this sticky article
+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)
--8<---------------cut here---------------end--------------->8---




  parent reply	other threads:[~2007-07-25 20:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-25 15:32 Tassilo Horn
2007-07-25 18:36 ` Reiner Steib
2007-07-25 19:32   ` Tassilo Horn
2007-07-25 20:17   ` Tassilo Horn [this message]
2007-08-12 11:15     ` Reiner Steib
2007-08-12 11:59       ` Tassilo Horn
2007-08-12 12:43         ` Reiner Steib
2007-08-13 13:03           ` Tassilo Horn
2007-08-13 14:04             ` Tassilo Horn
2007-08-14  5:18               ` Katsumi Yamaoka
2007-08-14  7:34                 ` Tassilo Horn
2007-08-14  9:02                   ` Katsumi Yamaoka
2007-08-14 10:41                     ` Tassilo Horn
2007-08-14  6:12               ` Katsumi Yamaoka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ir888cgd.fsf@baldur.tsdh.de \
    --to=tassilo@member.fsf.org \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).