unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* simple patch for `align.el'
@ 2004-10-23 22:38 Paul Pogonyshev
  2004-10-24  0:17 ` John Wiegley
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Pogonyshev @ 2004-10-23 22:38 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 629 bytes --]

Try typing

  a = 0;
  counter = 0;

then select this region and `M-x align' it.  The first line will have a
space followed by a tab, which is not good and is frowned upon by the
`whitespace' module.  The simple patch below fixes this.

I have to admit I didn't care to understand all the code in `align.el',
but I'm absolutely sure the patch is safe and works.


2004-10-24  Paul Pogonyshev  <pogonyshev@gmx.net>

        * align.el (align-areas): Delete whitespace before reindenting, so
        that tabs are never placed after spaces.


My mailer currently mangles tabs, so I attach the patch instead of inlining
it.

Paul



[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 775 bytes --]

--- align.el	01 Sep 2003 18:45:04 +0300	1.13
+++ align.el	24 Oct 2004 00:36:41 +0300	
@@ -1212,6 +1212,14 @@ have been aligned.  No changes will be m
 	      (cond ((< gocol 0) t)     ; don't do anything
 		    ((= cur gocol) t)   ; don't need to
 		    ((< cur gocol)      ; just add space
+		     ;; FIXME: It is stated above that "...the
+		     ;;	       whitespace to be modified was already
+		     ;;	       deleted by `align-region', all we have
+		     ;;	       to do here is indent."  However, this
+		     ;;	       doesn't seem to be true, so we first
+		     ;;	       delete the whitespace to avoid tabs
+		     ;;	       after spaces.
+		     (delete-horizontal-space t)
 		     (indent-to gocol))
 		    (t
 		     ;; This code works around an oddity in the

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: simple patch for `align.el'
  2004-10-23 22:38 simple patch for `align.el' Paul Pogonyshev
@ 2004-10-24  0:17 ` John Wiegley
  2004-10-24  7:15   ` David Kastrup
  0 siblings, 1 reply; 3+ messages in thread
From: John Wiegley @ 2004-10-24  0:17 UTC (permalink / raw)


Paul Pogonyshev <pogonyshev@gmx.net> writes:

> then select this region and `M-x align' it.  The first line will
> have a space followed by a tab, which is not good and is frowned
> upon by the `whitespace' module.  The simple patch below fixes this.

The patch looks fine enough to me.  Just take care that the deletion
does not adversely affect any markers.  I remember having lots of
subtle bugs with that in the past.  I'd advise testing this change
across a reasonably large file, and then diff'ing to make sure that
only the desired fix results.

John

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

* Re: simple patch for `align.el'
  2004-10-24  0:17 ` John Wiegley
@ 2004-10-24  7:15   ` David Kastrup
  0 siblings, 0 replies; 3+ messages in thread
From: David Kastrup @ 2004-10-24  7:15 UTC (permalink / raw)
  Cc: emacs-devel

John Wiegley <johnw@gnu.org> writes:

> Paul Pogonyshev <pogonyshev@gmx.net> writes:
>
>> then select this region and `M-x align' it.  The first line will
>> have a space followed by a tab, which is not good and is frowned
>> upon by the `whitespace' module.  The simple patch below fixes this.
>
> The patch looks fine enough to me.  Just take care that the deletion
> does not adversely affect any markers.  I remember having lots of
> subtle bugs with that in the past.

Good point.  The easiest way to do that is to _first_ insert the tab,
then remove the spaces.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

end of thread, other threads:[~2004-10-24  7:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-23 22:38 simple patch for `align.el' Paul Pogonyshev
2004-10-24  0:17 ` John Wiegley
2004-10-24  7:15   ` David Kastrup

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).