From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Raffaele Ricciardi Newsgroups: gmane.emacs.help Subject: Re: `align-regexp' fails in Lisp code Date: Fri, 12 Jul 2013 01:29:33 +0200 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1373585418 24700 80.91.229.3 (11 Jul 2013 23:30:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Jul 2013 23:30:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 12 01:30:20 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UxQJX-0006XX-ML for geh-help-gnu-emacs@m.gmane.org; Fri, 12 Jul 2013 01:30:19 +0200 Original-Received: from localhost ([::1]:40988 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxQJX-0006KE-59 for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Jul 2013 19:30:19 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 39 Original-X-Trace: individual.net mUIyI8vtnERl88KR3Ubu6ASrEtIs4vGiU25ejElMfzqzpMaJ1A Cancel-Lock: sha1:JDxNBi25yaM+YqhYNb/m29/ImSQ= User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130215 Thunderbird/17.0.3 In-Reply-To: Original-Xref: usenet.stanford.edu gnu.emacs.help:199801 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:92068 Archived-At: On 10/07/13 05:14, Michael Heerdegen wrote: > Leo Liu 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))