pjw@uk.ac.warwick.cs (Phil Wilkins) (02/15/89)
When-ever I post a followup article, and include bits of the original using C-c C-y, it marks the yanked lines with 3 spaces, but I don't want 3 spaces, I want a nice little ">" as I find them nice to look at. So I found what C-c C-y was bound to, "mail-yank-original", I then hunted down it's source. It tells me that I can indent any number or spaces including 0, but nothing else, just spaces. Aaaaaarrrrrrgggg! Help me please, as I'm fed up with " " as a prefix as I think it's both unclear, and ugly. Phil W -- /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ | Theoretically I can be contacted thus, but don't bet on it... | |Email: pjw@cs.warwick.ac.uk (once you can get the thing as far as Europe) | |Snail: Phil Wilkins, CS Department, University of Warwick, Coventry CV4 7AL| \___________________________________________________________________________/
mmatlack@andrew.GE.COM (Mike Matlack, 609/866-6612) (02/16/89)
Phil Watkins needed a mail-yank-original that allows the insertion of an arbitrary string (such as "> ") before each line of a yanked mail message, instead of the default x number of spaces. I use the following redefinition of mail-yank-original...not sure from whom I got it: (defun mail-yank-original (arg) "Insert the message being replied to, if any (in rmail). Puts point before the text and mark after. Adds a > character before the yanked message. A nonnumeric arg means don't delete any header fields." (interactive "P") (if mail-reply-buffer (let ((start (point))) (delete-windows-on mail-reply-buffer) (insert-buffer mail-reply-buffer) (if (consp arg) nil (mail-yank-clear-headers start (mark)) (while (< (point) (mark)) (beginning-of-line) (if (boundp '*mail-yank-line-prefix*) (insert-string *mail-yank-line-prefix*) (insert-string "> ")) (next-line 1))) (exchange-point-and-mark) (if (not (eolp)) (insert ?\n))))) If the variable *mail-yank-line-prefix* is not bound, this function will insert a "> " before each line. Otherwise, it will insert the string bound to this variable. -- MikeM mmatlack@atl.ge.com or mmatlack%atl.decnet@ge-crd.arpa ...!mcnc!ge-rtp!atl.ge.com!mmatlack
warsaw@rtg.cme.nbs.gov (Barry A. Warsaw) (02/17/89)
In article <1187@ubu.warwick.UUCP> pjw@uk.ac.warwick.cs (Phil Wilkins) writes: This is my first posting of elisp source so it may not be the cleanest chunk of code to come around, but it definitely does what Phil and many others want. > When-ever I post a followup article, and include bits of the > original using C-c C-y, it marks the yanked lines with 3 spaces, but I > don't want 3 spaces, I want a nice little ">" as I find them nice to > look at. So I found what C-c C-y was bound to, "mail-yank-original", I > then hunted down it's source. It tells me that I can indent any number > or spaces including 0, but nothing else, just spaces. Aaaaaarrrrrrgggg! > Help me please, as I'm fed up with " " as a prefix as I think it's > both unclear, and ugly. > Phil W > -- I've also wanted this for a long time, not only in posting followup articles in gnus, but also for replying to rmail and any other kinds of electronic article replies. I took a look at the relevant function "mail-yank-original", and saw that the function call "indent-rigidly" was the one that actually stuck the (dreaded) spaces in the indent. So I looked at indent-rigidly and found that with just a bit of modification, you could make the function insert an arbitrary character (or string of characters) instead of a space. I also added a check to see if the first character is the same as the insertion character, and if it is, no space is put after the insertion character. Example: if this is the original piece of article: > What I'd like to do is put something other than I have something that will do this And I yank it with this code, I'll get this in my reply buffer: >> What I'd like to do is put something other than > I have something that will do this I suppose you could extend this concept a bit more, if you wanted to, or perhaps, clean it up a bit. Seems to me, this would be an easy and useful modification to the standard distrib. Anyway, there are two functions below; "indent-with-char" which is basically modified from "indent-rigidly". I renamed this because I don't know where else "indent-rigidly" might be used. Then I modified "mail-yank-original" letting this overload the old function. Finally, it seems as though everything that does a reply (rmail, gnus, rnews) calls the function "mail-setup" before the reply but after the old "yank-original" gets loaded, and "mail-setup" executes "mail-setup-hook" so I put the following line in my .emacs file: ;; ;; mail setup hook for using new yank-original ;; (setq mail-setup-hook '(lambda () (load "yankorig"))) Of course, yankorig.el was on my load-path so the old "yank-original" gets overloaded and wha-la! Here then is yankorig.el, enjoy: ;; yankorig.el ;; ;; inserts a user-selected character at the beginning of a reply line ;; ;; This file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY. No author or distributor ;; accepts responsibility to anyone for the consequences of using it ;; or for whether it serves any particular purpose or works at all, ;; unless he says so in writing. Refer to the GNU Emacs General Public ;; License for full details. ;; Everyone is granted permission to copy, modify and redistribute ;; this file, but only under the conditions described in the ;; GNU Emacs General Public License. A copy of this license is ;; supposed to have been given to you along with GNU Emacs so you ;; can know your rights and responsibilities. It should be in a ;; file named COPYING. Among other things, the copyright notice ;; and this notice must be preserved on all copies. ;; NAME: Barry A. Warsaw USMAIL: National Institute of Standards ;; TELE: (301) 975-3460 and Technology (formerly NBS) ;; UUCP: {...}!uunet!cme-durer!warsaw Rm. B-124, Bldg. 220 ;; ARPA: warsaw@cme.nbs.gov Gaithersburg, MD 20899 ;; or: warsaw@cme-durer.arpa ;; ;; Modification history: ;; ;; 16-Feb-1989 by baw: modified funcs "indent-rigidly", "mail-yank-original" ;; (setq yank-character ">") (defun indent-with-char (start end arg) "Indent all lines starting in the region. Do this by inserting ARG number of characters at the beginning of the line. Character to insert is defined by the variable yank-character." (interactive "r/np") (save-excursion (goto-char end) (setq end (point-marker)) (goto-char start) (or (bolp) (forward-line 1)) (while (< (point) end) (let ((indent (current-indentation))) (delete-region (point) (progn (skip-chars-forward " \t") (point))) (or (eolp) (insert-char (string-to-char yank-character) arg)) (if (not (char-equal (string-to-char yank-character) (char-after (point)))) (insert-char (string-to-char " ") 1))) (forward-line 1)) (move-marker end nil))) (defun mail-yank-original (arg) "Insert the message being replied to, if any (in rmail). Puts point before the text and mark after. Indents each nonblank line ARG spaces (default 3). Just \\[universal-argument] as argument means don't indent and don't delete any header fields." (interactive "P") (if mail-reply-buffer (let ((start (point))) (delete-windows-on mail-reply-buffer) (insert-buffer mail-reply-buffer) (if (consp arg) nil (mail-yank-clear-headers start (mark)) (indent-with-char start (mark) (if arg (prefix-numeric-value arg) 1))) (exchange-point-and-mark) (if (not (eolp)) (insert ?\n)))))