From: Emanuel Berg <moasen@zoho.com>
To: help-gnu-emacs@gnu.org
Subject: Re: replace deprecated function ?
Date: Fri, 16 Feb 2018 17:57:45 +0100 [thread overview]
Message-ID: <861shkdg8m.fsf@zoho.com> (raw)
In-Reply-To: p62fa50j2l@news4.newsguy.com
B. T. Raven wrote:
> Thanks, Joost and Emanuel. See below.
Here is the best version [1] so far because
I got away with the redundant input data and
you then use the `query-replace' interface
(indeed the very function) which is better than
the crude `yes-or-no-p'.
(defun replace-list-ask-3 (dict)
(let ((re (string-join (mapcar #'car dict) "\\|")))
(save-excursion
(goto-char (point-min))
(while (re-search-forward re nil t)
(let*((match-string (match-string-no-properties 0))
(default (cdr (assoc match-string dict))) )
(when default
(query-replace match-string default nil
(match-beginning 0)
(match-end 0) )))))))
;; (replace-list-ask-3 '(("james" . "James") ("blish" . "Blish")))
[1] http://user.it.uu.se/~embe8573/emacs-init/replace-list.el
--
underground experts united
http://user.it.uu.se/~embe8573
next prev parent reply other threads:[~2018-02-16 16:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-13 18:16 replace deprecated function ? B. T. Raven
2018-02-13 19:27 ` Emanuel Berg
2018-02-13 20:00 ` Emanuel Berg
2018-02-13 22:41 ` B. T. Raven
2018-02-13 23:19 ` Joost Kremers
2018-02-13 23:26 ` Emanuel Berg
2018-02-13 23:33 ` Emanuel Berg
2018-02-14 2:36 ` Yuri Khan
[not found] ` <mailman.9079.1518575794.27995.help-gnu-emacs@gnu.org>
2018-02-14 3:34 ` Emanuel Berg
[not found] ` <mailman.9067.1518563981.27995.help-gnu-emacs@gnu.org>
2018-02-14 23:04 ` B. T. Raven
2018-02-16 16:57 ` Emanuel Berg [this message]
2018-02-16 20:19 ` B. T. Raven
2018-02-13 21:14 ` Kaushal Modi
[not found] ` <mailman.9061.1518556487.27995.help-gnu-emacs@gnu.org>
2018-02-14 23:31 ` B. T. Raven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=861shkdg8m.fsf@zoho.com \
--to=moasen@zoho.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.