[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX] Insert counter in Emacs tex file
From: |
Rodolfo Medina |
Subject: |
Re: [AUCTeX] Insert counter in Emacs tex file |
Date: |
Mon, 27 Aug 2018 09:35:18 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
David Kastrup <address@hidden> writes:
> With regard to functions: instead of using keyboard macros, you can
> first call some complex command like query-replace-regexp, then use
>
> C-x ESC ESC (translated from C-x <escape> <escape>) runs the command
> repeat-complex-command (found in global-map), which is an interactive
> compiled Lisp function in ‘simple.el’.
>
> It is bound to <again>, <redo>, C-x M-:, C-x M-ESC.
>
> (repeat-complex-command ARG)
>
> Edit and re-evaluate last complex command, or ARGth from last.
> A complex command is one which used the minibuffer.
> The command is placed in the minibuffer as a Lisp form for editing.
> The result is executed, repeating the command as changed.
> If the command has been changed or is not the most recent previous
> command it is added to the front of the command history.
> You can use the minibuffer history commands M-n and M-p
> to get different commands to edit and resubmit.
>
> [back]
>
> in order to get "a Lisp form for editing" which you can copy and paste
> into a function definition.
Thanks, that was helpful. With the help of `repeat-complex-command', I
defined:
(defun my-cancel-bar-numbers ()
(interactive)
(replace-regexp "\\\\bar %[0-9]+" "\\\\bar" nil (if (use-region-p)
(region-beginning)) (if (use-region-p) (region-end)) nil)
)
and
(defun my-number-bars ()
(interactive)
(replace-regexp "\\\\bar" (quote (replace-eval-replacement concat "\\\\bar %"
(replace-quote (+ 2 replace-count)))) nil (if (use-region-p)
(region-beginning)) (if (use-region-p) (region-end)) nil)
)
After all, I can use them separately, preceeded by `M-h'. But do you think
it's possible, in the second definition, to replace not only `\bar' but the
whole line including it...? That way, I could do without the first
definition... I mean, use `replace-regexp' with sort of jolly expressions:
replace `\bar' and whatever comes after it in the line...
Thanks,
Rodolfo