all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* `quick-calc` inside `query-replace` breaks
@ 2015-07-29 22:39 Tom Roche
  2015-09-10 18:59 ` Tom Roche
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Roche @ 2015-07-29 22:39 UTC (permalink / raw)
  To: help-gnu-emacs


summary: 2 or 3 branched questions (at end) about a change in behavior (24.3.1 -> 24.4.1) when running interactive `quick-calc` inside interactive `query-replace`.

details:

Until yesterday I was using version='GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.8.4)' (on Debian) and frequently used workflows like the following:

I would compose text with markdown-style footnotes, but instead of enumerating them while composing (which is brittle WRT text rearrangement :-), I would defer the enumeration until I was done. Hence

version#=0 ~=
> Foo![NNN] but also bar[NNN] and baz[NNN].
>
> ===
>
> [NNN]: ...
> [NNN]: ...
> [NNN]: ...

where 'NNN' isa "numerator" (i.e., a template for integers), and '===' isa "fence" between text and footnotes. On "done-ness," I would

1. `query-replace` the "first two" numerators (after the beginning of the document, and after the fence) with '1'

2. recording a macro that interactively `query-replace`d each successive pair of numerators with successive integers.

3. run the macro, checking that the "footnote" matched its text. (This is non-trivial, because

* a footnote can be used more than once
* sometimes I use a footnote inside another footnote

) The macro relied on the facts that

* `query-replace` has an argument stack, accessible via arrow keys: one can retrieve previously-used arguments for the current call.

* `query-replace` arguments could be modified *from the stack*. E.g., after doing `query-replace NNN 1', I could record the following sequence:

1. `M-x query-replace`

2. sequence=[2*<up> RET] to retrieve the 'NNN' from the stack, and make it the first argument in the current call

3. sequence=[2*<up> C-k] to copy the '1' (from the previous call) from the stack to the kill-ring

4. `M-x quick-calc` inside the `query-replace`

5. sequence=[C-y + 1 RET] to increment the numeric input (in this case, '1') and exit `quick-calc`

6. C-y to return the result of the incrementation (in this case, 2) from `quick-calc` to the argument list for the current `query-replace` call

7. RET to call `query-replace` to do the work.

Seems complex now that I've typed it :-) but after doing it so many times, it's in my "muscle memory." So I was annoyed to discover just now, after finally upgrading to {Jessie, 'GNU Emacs 24.4.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.5)'}, that I can no longer do this! because when I call `quick-calc` inside the `query-replace`, I immediately get the error

> byte-code: Wrong number of arguments: (lambda nil (interactive) (log-BP4)), 2

which abends `quick-calc`, which abends macro recording. So I'd like to know:

1. Is the new behavior a bug or a feature (i.e., Working As Designed)?

1.1. (if a bug) Has this been previously reported?

1.1.1. (if so) apologies if this is a FAQ, but a quick websearch showed me nothing.

1.1.2. (if not) To where should it be reported?

1.2. (if WAD) How can I workaround the new behavior to do what I want (possibly more effectively)?

TIA, Tom Roche <Tom_Roche@pobox.com>



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: `quick-calc` inside `query-replace` breaks
  2015-07-29 22:39 `quick-calc` inside `query-replace` breaks Tom Roche
@ 2015-09-10 18:59 ` Tom Roche
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Roche @ 2015-09-10 18:59 UTC (permalink / raw)
  To: help-gnu-emacs


Tom Roche Wed, 29 Jul 2015 18:39:25 -0400[1]
> after finally upgrading to {[Debian] Jessie, 'GNU Emacs 24.4.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.5)'}, [calling] `quick-calc` inside [`query-replace` immediately gets error=]

> > byte-code: Wrong number of arguments: (lambda nil (interactive) (log-BP4)), 2

> which abends `quick-calc`, which abends macro recording. So I'd like to know:

> 1. Is the new behavior a bug or a feature (i.e., Working As Designed)?

> 1.1. (if a bug) Has this been previously reported?

> 1.1.1. (if so) apologies if this is a FAQ, but a quick websearch showed me nothing.

> 1.1.2. (if not) To where should it be reported?

> 1.2. (if WAD) How can I workaround the new behavior to do what I want (possibly more effectively)?

Regarding the latter question: macro counters[2] deliver appropriate functionality for the vast majority of my usecases, and hopefully will be useful for OP. That being said, I'd still like to know why one can no longer run `quick-calc` inside `query-replace`. (And possibly other interactive functions?)

HTH, Tom Roche <Tom_Roche@pobox.com>

[1]: http://lists.gnu.org/archive/html/help-gnu-emacs/2015-07/msg00772.html
[2]: http://ericjmritz.name/2013/09/25/using-macro-counters-in-emacs/



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-10 18:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-29 22:39 `quick-calc` inside `query-replace` breaks Tom Roche
2015-09-10 18:59 ` Tom Roche

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.