[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: replace-regexp, the byte-compiler, docstrings, and suggestions

From: Emanuel Berg
Subject: Re: replace-regexp, the byte-compiler, docstrings, and suggestions
Date: Sat, 18 Oct 2014 00:52:08 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Stefan Monnier <> writes:

>> Yeah, probably. I tried in the Linux VT and in X
>> (with xterm), with and without tmux on both: in the
>> console C-4 just inserts a "4", in X C-4 is C-\. I
>> only have emacs-nox installed but I'm happy with
>> `C-u N' so this doesn't bother me.
> You can also use M-N, BTW, which should work also in
> text terminals.


OK, so I won't suggest a "block cite" function as
there is one, perhaps two, already.

Still, any comments on:

- instead of offering Elisp in the help, give a
  function that does exactly that
- have the byte-compiler give this reference as well
  (optimally the same information as in the help, so
  no need to compile and then check out the help)

- could this be optimized transparently? (perhaps a
  bit risky? with a very small gain at that - no, I'm
  happy with what I originally proposed)

- even as it stands, the reason the "interactive"
  `replace-regexp' shouldn't be used is:

    This function is usually the wrong thing to use in a Lisp program.
    What you probably want is a loop like this:
      (while (re-search-forward REGEXP nil t)
        (replace-match TO-STRING nil nil))
    which will run faster and will not set the mark or print anything.

but the interface to `replace-regexp' is:
(replace-regexp REGEXP TO-STRING &optional DELIMITED

So we offer a function. When someone uses it the
compiler complains. Because the compiler doesn't say
much, the user has to check out the help where he is
given the code. But the code doesn't even cover the
interface of the "forbidden" `replace-regexp'. So he
has to figure out the missing parts. By this time
frustration will run high especially because
`replace-regexp' - the incorrect use - probably worked
just fine.

I'm telling you. It is not a big deal. It is a detail.
But it is the details that make the big picture.
underground experts united

reply via email to

[Prev in Thread] Current Thread [Next in Thread]