From: "B. T. Raven" <btraven@nihilo.net>
To: help-gnu-emacs@gnu.org
Subject: Re: replace deprecated function ?
Date: Fri, 16 Feb 2018 14:19:23 -0600 [thread overview]
Message-ID: <p67ec803a6@news1.newsguy.com> (raw)
In-Reply-To: <861shkdg8m.fsf@zoho.com>
On 2/16/2018 10:57, Emanuel Berg wrote:
> 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
>
Thanks, Emanuel. In order to conserve muscle memory I used the
(read-key) kludge instead of y-or-n-p. My only goal was to get rid of
query-replace-regexp-eval so the only thing I used from your code was
re-search-forward (C function) instead of search-forward-regexp. It
looks like your solution is more general but I don't currently have any
application for it other than superscripting numerals (footnotes) here
and there.
Ed
next prev parent reply other threads:[~2018-02-16 20:19 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
2018-02-16 20:19 ` B. T. Raven [this message]
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=p67ec803a6@news1.newsguy.com \
--to=btraven@nihilo.net \
--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.