unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: [ELPA] New package: xr
Date: Wed, 27 Feb 2019 17:22:16 +0100	[thread overview]
Message-ID: <23E9F007-5B84-45C6-9933-5A1220058CAA@acm.org> (raw)
In-Reply-To: <875zt5feys.fsf@web.de>

27 feb. 2019 kl. 16.06 skrev Michael Heerdegen <michael_heerdegen@web.de>:
> 
> Would it be possible to define a variable to control what kind of
> operators `xr--postfix' chooses?  Currently the verbose names are
> hardcoded, and even if there is no perfectly nice solution, it would be
> good if there was some way to control this.  I'm not sure if there are
> other places besides `xr--postfix' where such a variable would be to
> consulted.

The identifiers chosen by xr will never suit the taste of everyone, but I couldn't make up my mind about what to do about it. I'd be interested in hearing what other people think.
One way would be to add an optional translation alist to xr:

(xr "a*.?"
    '((zero-or-more . 0+) (nonl . not-newline)))
=> (seq (0+ "a") (opt not-newline))

but this could be done almost as easily by post-processing the resulting list tree, maybe like this:

(defun rename-rx (substitution-alist rx)
  "Rename all identifiers in RX according to SUBSTITUTION-ALIST."
  (cond
   ((symbolp rx) (alist-get rx substitution-alist rx))
   ((consp rx)
    ;; Translate the first element of each list even if not a symbol,
    ;; to allow translation of ? and ?? (space and ?).
    (cons (alist-get (car rx) substitution-alist (car rx))
	  (mapcar (lambda (elem) (rename-rx substitution-alist elem))
		  (cdr rx))))
   (t rx)))

Post-processing is more generally powerful since it can do structural replacement and not mere symbol replacement.

A customisable setting would also work, but I prefer keeping xr purely functional.




  reply	other threads:[~2019-02-27 16:22 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-01 14:09 [ELPA] New package: xr Mattias Engdegård
2019-02-01 15:25 ` Clément Pit-Claudel
2019-02-01 15:42   ` Eli Zaretskii
2019-02-01 18:39     ` Clément Pit-Claudel
2019-02-01 15:51   ` Mattias Engdegård
2019-02-01 18:41     ` Clément Pit-Claudel
2019-02-02  9:43       ` Mattias Engdegård
2019-02-02 15:15         ` Mattias Engdegård
2019-02-02 18:41           ` Clément Pit-Claudel
2019-02-03  9:37             ` Mattias Engdegård
2019-02-03 20:11             ` Juri Linkov
2019-02-03 21:04               ` Mattias Engdegård
2019-02-03 21:13               ` Clément Pit-Claudel
2019-02-05 16:15 ` Stefan Monnier
2019-02-05 22:37   ` Michael Heerdegen
2019-02-06  0:04     ` Mattias Engdegård
2019-02-05 23:00   ` Michael Heerdegen
2019-02-06  0:11     ` Stefan Monnier
2019-02-06  0:25       ` Noam Postavsky
2019-02-06  0:34         ` Michael Heerdegen
2019-02-06  1:36         ` Stefan Monnier
2019-02-06 12:43       ` Mattias Engdegård
2019-02-07  4:34         ` pcre2el Richard Stallman
2019-02-07  7:11           ` pcre2el John Wiegley
2019-02-07 14:54           ` pcre2el Stefan Monnier
2019-02-06  0:02   ` [ELPA] New package: xr Mattias Engdegård
2019-02-06  0:14     ` Stefan Monnier
2019-02-06  7:02   ` Richard Stallman
2019-02-06 15:39     ` Eli Zaretskii
2019-02-07  4:36       ` Richard Stallman
2019-02-07 14:37         ` Eli Zaretskii
2019-02-08  3:21           ` Richard Stallman
2019-02-08  3:50             ` Stefan Monnier
2019-02-08  7:18               ` Eli Zaretskii
2019-02-08 10:06                 ` Stephen Berman
2019-02-09  3:37                   ` Richard Stallman
2019-02-09  8:03                     ` Eli Zaretskii
2019-02-09  3:38                 ` Richard Stallman
2019-02-09  8:05                   ` Eli Zaretskii
2019-02-10  5:51                     ` Richard Stallman
2019-02-10 15:12                       ` Eli Zaretskii
2019-02-11  5:38                         ` Richard Stallman
2019-02-10  5:51                     ` Richard Stallman
2019-02-10 15:14                       ` Eli Zaretskii
2019-02-09  3:37               ` Richard Stallman
2019-02-27 15:06 ` Michael Heerdegen
2019-02-27 16:22   ` Mattias Engdegård [this message]
2019-02-27 17:09     ` Michael Heerdegen
2019-02-28 14:10       ` Mattias Engdegård
2019-02-28 14:34         ` Clément Pit-Claudel
2019-02-28 23:06         ` Stefan Monnier
2019-03-01 13:39           ` Mattias Engdegård
2019-03-01 13:51             ` Stefan Monnier
2019-03-01  5:29         ` Van L
2019-03-01 13:54           ` Stefan Monnier
2019-03-01 15:25         ` Michael Heerdegen

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23E9F007-5B84-45C6-9933-5A1220058CAA@acm.org \
    --to=mattiase@acm.org \
    --cc=emacs-devel@gnu.org \
    --cc=michael_heerdegen@web.de \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).