Gnus development mailing list
 help / color / mirror / Atom feed
* Save an article with its subject as default name
@ 2016-05-27 13:38 Dmitry Alexandrov
  2016-05-29  2:33 ` Dmitry Alexandrov
  2016-06-03 19:48 ` Reiner Steib
  0 siblings, 2 replies; 6+ messages in thread
From: Dmitry Alexandrov @ 2016-05-27 13:38 UTC (permalink / raw)
  To: ding

Hello.

I’m quite new to Gnus, and I was quite surprised when found that in
contrast to any modern MUA, when I save a single message (‘article’) in
a file (‘o’), Gnus does not suggest to name it after subject.  The
manual [0] does not help a lot.

[0] https://www.gnu.org/software/emacs/manual/html_node/gnus/Saving-Articles.html

Ok, I have to implement it myself (am I right or am I trying to
re-invent a wheel?), that should not be so hard, probably something like
that:

(require 'subr-x)

(defvar gnus-rmail-save-name-extension ".eml")

(defun gnus-subject-save-name (_newsgroup headers &optional _last-file)
  "Generate file name from subject."
  (let ((subject (mail-header-subject headers)))
    (expand-file-name
     (*file-name-sanitize
      (concat
       (if (string-blank-p subject)
           (int-to-string (mail-header-number headers)) ; fallback to number
         subject)
       gnus-rmail-save-name-extension))
     gnus-article-save-directory)))

(setq gnus-rmail-save-name 'gnus-subject-save-name)

One problem though: ‘*file-name-sanitize’ is just a placeholder yet,
i. e. I need a function that takes an arbitrary string and return string
that is safe to use as a filename.  It is not hard to implement either,
of course, but that looks to me as a pretty common need for any program
that works with files, so I suppose GNU Emacs itself or some library
should have it already.  I cannot find it though.  Could you turn me in
right direction, please?




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-06-08 12:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-27 13:38 Save an article with its subject as default name Dmitry Alexandrov
2016-05-29  2:33 ` Dmitry Alexandrov
2016-05-29  6:11   ` Emanuel Berg
2016-06-03 19:48 ` Reiner Steib
2016-06-04 11:18   ` Emanuel Berg
2016-06-08 12:33   ` Dmitry Alexandrov

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