From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: align-regexp problem when called from lisp code Date: Thu, 08 Aug 2013 13:32:32 +0200 Message-ID: <87wqnws9in.fsf@thinkpad.tsdh.org> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1375972749 23100 80.91.229.3 (8 Aug 2013 14:39:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 Aug 2013 14:39:09 +0000 (UTC) Cc: help-gnu-emacs To: Luca Ferrari Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Aug 08 16:39:11 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 1V7RMs-0006iX-SA for geh-help-gnu-emacs@m.gmane.org; Thu, 08 Aug 2013 16:39:10 +0200 Original-Received: from localhost ([::1]:46002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7RMs-0002WA-H0 for geh-help-gnu-emacs@m.gmane.org; Thu, 08 Aug 2013 10:39:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7OSO-0004VJ-Ki for help-gnu-emacs@gnu.org; Thu, 08 Aug 2013 07:32:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V7OSI-0001Pf-Gm for help-gnu-emacs@gnu.org; Thu, 08 Aug 2013 07:32:40 -0400 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:37132) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7OSI-0001PC-BM for help-gnu-emacs@gnu.org; Thu, 08 Aug 2013 07:32:34 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by deliver.uni-koblenz.de (Postfix) with ESMTP id DE4B51A86AE; Thu, 8 Aug 2013 13:32:33 +0200 (CEST) X-Virus-Scanned: amavisd-new at uni-koblenz.de Original-Received: from deliver.uni-koblenz.de ([127.0.0.1]) by localhost (deliver.uni-koblenz.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Iug-0k2bCARg; Thu, 8 Aug 2013 13:32:33 +0200 (CEST) X-CHKRCPT: Envelopesender noch tsdh@gnu.org Original-Received: from thinkpad.tsdh.org (tsdh.uni-koblenz.de [141.26.67.142]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTPSA id 848641A86AC; Thu, 8 Aug 2013 13:32:33 +0200 (CEST) In-Reply-To: (Luca Ferrari's message of "Thu, 8 Aug 2013 12:34:02 +0200") User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 141.26.64.15 X-Mailman-Approved-At: Thu, 08 Aug 2013 10:38:34 -0400 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:92779 Archived-At: Luca Ferrari writes: > if I use (align-regexp) interactively with a region marked all works > as expected, but if I call it from the following piece of lisp: > > (defun fluca1978/align-assignments () > (interactive ) > (let ( (line-moving-increment) ) > (align-regexp (point) (mark) "=" ) > (deactivate-mark) ) ) You should make it explicit that the command wants a region using the interactive spec. Also, `align-regexp' mangles the regexp given to it a bit. I guess this does what you want: --8<---------------cut here---------------start------------->8--- (defun fluca1978/align-assignments (beg end) (interactive "r") (align-regexp beg end "\\(\\s-*\\)=")) --8<---------------cut here---------------end--------------->8--- When applied to the following region a = b ab = t + i flubble = 17 foo = bar - baz it aligns it like so: a = b ab = t + i flubble = 17 foo = bar - baz HTH, Tassilo