all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Raffaele Ricciardi <rfflrccrd@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: `align-regexp' fails in Lisp code
Date: Fri, 12 Jul 2013 01:29:33 +0200	[thread overview]
Message-ID: <b48tevFhr5hU1@mid.individual.net> (raw)
In-Reply-To: <mailman.723.1373426169.12400.help-gnu-emacs@gnu.org>

On 10/07/13 05:14, Michael Heerdegen wrote:
> Leo Liu <sdl.web@gmail.com> writes:
>
>> On 2013-07-10 08:11 +0800, Raffaele Ricciardi wrote:
>>> Marking the whole buffer and calling `align-regexp' interactively does
>>> work
>>
>> Because the function works on a region as stated in its doc-string.
>
> If that's right (it seems so), then the doc-string should clearly say
> that this command is not for non-interactive use, or how it can be
> called from Lisp.

Two positions make a region, hence the call:

     (align-regexp (point-min) (point-max) " hides ")

is correct.

The problem is that - I had to look into Lisp code to understand - the 
regexp that you enter in the mini-buffer is not the regexp that 
`align-regexp' receives, because of a conversion applied by the 
`interactive' form inside the command.  Hence I agree with you - but for 
a different reason - that the documentation should say how the command 
could be called from Lisp.

Here is a wrapper to call `align-regexp' from Lisp with no prefix arg :

(defun align-regexp-function (^start ^end ^regexp)
   "Like `align-regexp' when no prefix arg was specified,
but callable from Lisp."
   ;; Convert arguments like the `interactive' form
   ;; in `align-regexp' does when no prefix arg was specified.
   (align-regexp ^start
                 ^end
                 (concat "\\(\\s-*\\)" ^regexp)
                 1
                 align-default-spacing
                 nil))


  parent reply	other threads:[~2013-07-11 23:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-10  0:11 `align-regexp' fails in Lisp code Raffaele Ricciardi
2013-07-10  2:58 ` Leo Liu
2013-07-10  3:14   ` Michael Heerdegen
2013-07-11 11:55     ` andrea crotti
2013-07-11 12:02       ` Nicolas Richard
     [not found]   ` <mailman.723.1373426169.12400.help-gnu-emacs@gnu.org>
2013-07-11 23:29     ` Raffaele Ricciardi [this message]
2013-07-12  0:26       ` Michael Heerdegen
     [not found]       ` <mailman.883.1373588795.12400.help-gnu-emacs@gnu.org>
2013-07-12 13:04         ` Raffaele Ricciardi
2013-07-12 23:16           ` Michael Heerdegen
2013-07-10  3:14 ` Le Wang
2013-07-12 13:18 ` Jambunathan K

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=b48tevFhr5hU1@mid.individual.net \
    --to=rfflrccrd@gmail.com \
    --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.