info-gnus-english
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature Request: Message-elide-region showing lines snipped and taki


From: Katsumi Yamaoka
Subject: Re: Feature Request: Message-elide-region showing lines snipped and taking a string
Date: Thu, 25 Dec 2008 15:08:15 +0900
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux)

>>>>> Sivaram Neelakantan wrote:
> The key C-c C-e currently elides a region of text and produces the
> following

> [...]

> Can it have some customised options to show the number of lines of
> text elided and also some text that the user can add?  Something like

> [snipped 5 lines]
> [5 lines of irrelevant text snipped]

Is the attached patch your taste?  This produces [snipped 5 lines]:

(setq message-elide-ellipsis "\n[snipped %l lines]\n\n")

> Ideally, [...] or [snipped x lines] can be made default with the
> option of the user being able to change the text.

I sometimes use `C-c C-e' to delete not only cited text but also
lines I wrote, so I think making it the default is not a good idea.

--8<---------------cut here---------------start------------->8---
--- message.el~ 2008-12-23 22:17:54 +0000
+++ message.el  2008-12-25 06:06:12 +0000
@@ -428,7 +428,9 @@
   :group 'message-various)
 
 (defcustom message-elide-ellipsis "\n[...]\n\n"
-  "*The string which is inserted for elided text."
+  "*The string which is inserted for elided text.
+%c, %l and %w will be substituted with the elided number of characters,
+lines and words respectively.  Use %% for a single %."
   :type 'string
   :link '(custom-manual "(message)Various Commands")
   :group 'message-various)
@@ -3419,8 +3421,24 @@
 An ellipsis (from `message-elide-ellipsis') will be inserted where the
 text was killed."
   (interactive "r")
-  (kill-region b e)
-  (insert message-elide-ellipsis))
+  (let ((c (abs (- e b)))
+       (l (count-lines b e))
+       (w (length (split-string (buffer-substring b e)))))
+    (kill-region b e)
+    (save-restriction
+      (narrow-to-region b b)
+      (insert message-elide-ellipsis)
+      (goto-char (point-min))
+      (while (re-search-forward "%[clw%]" nil t)
+       (replace-match (cond ((eq (char-before) ?c)
+                             (number-to-string c))
+                            ((eq (char-before) ?l)
+                             (number-to-string l))
+                            ((eq (char-before) ?w)
+                             (number-to-string w))
+                            ((eq (char-before) ?%)
+                             "%"))))
+      (goto-char (point-max)))))
 
 (defvar message-caesar-translation-table nil)
 
--8<---------------cut here---------------end--------------->8---


reply via email to

[Prev in Thread] Current Thread [Next in Thread]