[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: comments in .mailrc treated inconsistently
From: |
Roland Winkler |
Subject: |
Re: comments in .mailrc treated inconsistently |
Date: |
Mon, 22 Aug 2005 15:47:23 +0200 |
On Mon Aug 22 2005 Richard M. Stallman wrote:
> The functions build-mail-abbrevs and build-mail-aliases are very
> similar. However, build-mail-abbrevs ignores comments (anything in a
> line that follows `# ') while build-mail-aliases doesn't do that.
>
> Why does it matter? The code in build-mail-aliases only looks
> for certain kinds of lines, which start with `source' or `alias'
> or `group'. Comment lines ought to be ignored anyway, as far
> as I can see.
>
> Have you encountered a particular case that fails?
> If so, please send a precise test case, and I'll debug it.
Here is an example:
alias smith address@hidden # great guy
build-mail-abbrevs removes such a comment at the end of a line so
that `smith' expands to address@hidden'. On the other hand,
build-mail-aliases yields a rather meaningless
address@hidden, #, great, guy'.
The patch below fixes this so that the behavior of
build-mail-aliases becomes consistent with the behavior of
build-mail-abbrevs. The new lines were simply copied from
build-mail-abbrevs in mailabbrev.el.
As I said, I do not know whether programs like /bin/mail understand
such comments. But I find these comments very helpful to organize
the entries in my .mailrc. The reason I want to put the comments in
the same line like an alias is that then I can much easier shuffle
the lines in my .mailrc.
Should this behavior be documented in the docstrings of
build-mail-aliases and build-mail-abbrevs and in the info node
(emacs)Mail Aliases? Only by digging into the code of
build-mail-abbrevs I discovered that the feature I wanted partly
exists already.
Roland
--- mailalias.el~ 2005-03-26 03:13:35.000000000 +0100
+++ mailalias.el 2005-08-22 15:20:11.000000000 +0200
@@ -265,6 +265,12 @@
(goto-char (point-max))
(or (eq (preceding-char) ?\n) (newline))
(goto-char (point-min))
+ ;; Delete comments from the file
+ (while (search-forward "# " nil t)
+ (let ((p (- (point) 2)))
+ (end-of-line)
+ (delete-region p (point))))
+ (goto-char (point-min))
;; handle "\\\n" continuation lines
(while (not (eobp))
(end-of-line)