Article View: news.software.nntp
Article #2773Re: simple elisp question... removing substrings?
From: Neil Jerram
Date: Sat, 30 Jul 1994 22:31
Date: Sat, 30 Jul 1994 22:31
29 lines
2084 bytes
2084 bytes
In article <ROBERT.94Jul30093150@steffi.demon.co.uk> robert@steffi.demon.co.uk (Robert Nicholson) writes:
(defun gnus-plain-save-name-without-hostname (newsgroup headers &optional last-file)
(let((prefix (substring newsgroup 0 7))
(suffix (substring newsgroup 7 nil)))
(if (string= prefix "steffi.")
(gnus-plain-save-name suffix headers last-file)
(gnus-plain-save-name newsgroup headers last-file))))
which does the job nicely however what I really wanted was something
that just took a string say "steffi.zsh-list" and removed the
"steffi." if it was there or just returned the full-string when it
wasn't. ie. so that I can provide a solution that just has _one_
(gnus-plain call rather than two but I didn't want to do (setq either.
It's just a question of moving the (if ...) construct:
(defun gnus-plain-save-name-without-hostname (newsgroup headers
&optional last-file)
(gnus-plain-save-name
(if (string-match "^steffi\\." newsgroup)
(substring newsgroup 7 nil)
newsgroup)
headers last-file))
This is one of the things I really like about Lisp.
Neil.
Technical Details
Message-ID:
<NJ104.94Jul30233132@hilsa.amtp.cam.ac.uk>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-gnu.emacs.help.mbox.zip!bga.com!news.sprintlink.net!hookup!ukma!gatech!howland.reston.ans.net!pipex!lyra.csx.cam.ac.uk!nj104References:
<ROBERT.94Jul30093150@steffi.demon.co.uk>Show Full Headers
Complete Article Headers
Message-ID: <NJ104.94Jul30233132@hilsa.amtp.cam.ac.uk> Subject: Re: simple elisp question... removing substrings? Date: Sat, 30 Jul 1994 22:31:32 +0000 From: nj104@amtp.cam.ac.uk (Neil Jerram) References: <ROBERT.94Jul30093150@steffi.demon.co.uk> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-gnu.emacs.help.mbox.zip!bga.com!news.sprintlink.net!hookup!ukma!gatech!howland.reston.ans.net!pipex!lyra.csx.cam.ac.uk!nj104 Newsgroups: gnu.emacs.help,gnu.emacs.gnus,news.software.nntp Organization: DAMTP, Cambridge University, UK Lines: 28 Distribution: world NNTP-Posting-Host: hilsa.amtp.cam.ac.uk In-reply-to: robert@steffi.demon.co.uk's message of 30 Jul 1994 08:31:50 GMT