all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* align-regexp not working as intended
@ 2013-03-18 10:15 Florian Lindner
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Lindner @ 2013-03-18 10:15 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

on my Emacs 24.2.1 7 / Arch align-regexp is not working like I expect it to:

I have a latex table:

    & $C_D$ & $C_L$ & $C_M$ & $C_D$ & $C_L$ & $C_M$ & $C_D$ & $C_L$ &
$C_M$ \\ \hline
    5-Spoke & $0.640$ & $0.396$ & $\approx 0$ & $0.599$ & $0.394$ &
$0.017$ & $0.599$ & $0.356$ & $0.019$ \\
    7-Spoke & $0.646$ & $0.407$ & $0.0017$ & $0.592$ & $0.377$ &
$0.0167$ & $0.606$ & $0.349$ & $0.0280$ \\
    DA Wheel & $0.649$ & $0.421$ & $-0.0004$ & $0.607$ & $0.392$ &
$0.0145$ & $0.614$ & $0.384$ & $0.024$ \\
    GenWheel Open & $0.640$ & $0.330$ & $0.0012$ & $0.613$ & $0.253$ &
$0.018$ & $0.660$ & $0.201$ & $0.031$ \\
    GenWheel Closed & $0.617$ & $0.302$ & $0.0015$ & $0.579$ & $0.280$
& $0.0206$ & $0.580$ & $0.281$ & $0.0206$ \\

This should be aligned at the &: M-x align-regexp & with the part
above as active region gives me:

                    & $C_D$ & $C_L$ & $C_M$ & $C_D$ & $C_L$ & $C_M$ &
$C_D$ & $C_L$ & $C_M$ \\ \hline
    5-Spoke         & $0.640$ & $0.396$ & $\approx 0$ & $0.599$ &
$0.394$ & $0.017$ & $0.599$ & $0.356$ & $0.019$ \\
    7-Spoke         & $0.646$ & $0.407$ & $0.0017$ & $0.592$ & $0.377$
& $0.0167$ & $0.606$ & $0.349$ & $0.0280$ \\
    DA Wheel        & $0.649$ & $0.421$ & $-0.0004$ & $0.607$ &
$0.392$ & $0.0145$ & $0.614$ & $0.384$ & $0.024$ \\
    GenWheel Open   & $0.640$ & $0.330$ & $0.0012$ & $0.613$ & $0.253$
& $0.018$ & $0.660$ & $0.201$ & $0.031$ \\
    GenWheel Closed & $0.617$ & $0.302$ & $0.0015$ & $0.579$ & $0.280$
& $0.0206$ & $0.580$ & $0.281$ & $0.0206$ \\

(you should swith your font to fixed-width now)

The align is fine at the first columns but somehow got off later...

What is the problem here?

If there is some problem with mail reader introduced line breaks or
font width, the entire posting is available here:
http://pastebin.com/raw.php?i=3JZiKiaS

Thanks!

Florian



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

* Re: align-regexp not working as intended
       [not found] <mailman.22392.1363601736.855.help-gnu-emacs@gnu.org>
@ 2013-03-18 18:39 ` jpkotta
  0 siblings, 0 replies; 2+ messages in thread
From: jpkotta @ 2013-03-18 18:39 UTC (permalink / raw)
  To: gnu.emacs.help; +Cc: help-gnu-emacs

On Monday, March 18, 2013 5:15:25 AM UTC-5, Florian Lindner wrote:
> Hello,
> 
> 
> 
> on my Emacs 24.2.1 7 / Arch align-regexp is not working like I expect it to:
> 
> 
> 
> I have a latex table:
> 
> 
> 
>     & $C_D$ & $C_L$ & $C_M$ & $C_D$ & $C_L$ & $C_M$ & $C_D$ & $C_L$ &
> 
> $C_M$ \\ \hline
> 
>     5-Spoke & $0.640$ & $0.396$ & $\approx 0$ & $0.599$ & $0.394$ &
> 
> $0.017$ & $0.599$ & $0.356$ & $0.019$ \\
> 
>     7-Spoke & $0.646$ & $0.407$ & $0.0017$ & $0.592$ & $0.377$ &
> 
> $0.0167$ & $0.606$ & $0.349$ & $0.0280$ \\
> 
>     DA Wheel & $0.649$ & $0.421$ & $-0.0004$ & $0.607$ & $0.392$ &
> 
> $0.0145$ & $0.614$ & $0.384$ & $0.024$ \\
> 
>     GenWheel Open & $0.640$ & $0.330$ & $0.0012$ & $0.613$ & $0.253$ &
> 
> $0.018$ & $0.660$ & $0.201$ & $0.031$ \\
> 
>     GenWheel Closed & $0.617$ & $0.302$ & $0.0015$ & $0.579$ & $0.280$
> 
> & $0.0206$ & $0.580$ & $0.281$ & $0.0206$ \\
> 
> 
> 
> This should be aligned at the &: M-x align-regexp & with the part
> 
> above as active region gives me:
> 
> 
> 
>                     & $C_D$ & $C_L$ & $C_M$ & $C_D$ & $C_L$ & $C_M$ &
> 
> $C_D$ & $C_L$ & $C_M$ \\ \hline
> 
>     5-Spoke         & $0.640$ & $0.396$ & $\approx 0$ & $0.599$ &
> 
> $0.394$ & $0.017$ & $0.599$ & $0.356$ & $0.019$ \\
> 
>     7-Spoke         & $0.646$ & $0.407$ & $0.0017$ & $0.592$ & $0.377$
> 
> & $0.0167$ & $0.606$ & $0.349$ & $0.0280$ \\
> 
>     DA Wheel        & $0.649$ & $0.421$ & $-0.0004$ & $0.607$ &
> 
> $0.392$ & $0.0145$ & $0.614$ & $0.384$ & $0.024$ \\
> 
>     GenWheel Open   & $0.640$ & $0.330$ & $0.0012$ & $0.613$ & $0.253$
> 
> & $0.018$ & $0.660$ & $0.201$ & $0.031$ \\
> 
>     GenWheel Closed & $0.617$ & $0.302$ & $0.0015$ & $0.579$ & $0.280$
> 
> & $0.0206$ & $0.580$ & $0.281$ & $0.0206$ \\
> 
> 
> 
> (you should swith your font to fixed-width now)
> 
> 
> 
> The align is fine at the first columns but somehow got off later...
> 
> 
> 
> What is the problem here?
> 
> 
> 
> If there is some problem with mail reader introduced line breaks or
> 
> font width, the entire posting is available here:
> 
> http://pastebin.com/raw.php?i=3JZiKiaS
> 
> 
> 
> Thanks!
> 
> 
> 
> Florian

align-regexp has an optional repeat argument which must be set to t to do what you want.  Here is a command that I use for these sorts of tasks:

(defun align-regexp-repeated (start stop regexp)
  "Like align-regexp, but repeated for multiple columns. See
http://www.emacswiki.org/emacs/AlignCommands"
  (interactive "r\nsAlign regexp: ")
  (let ((spacing 1)
        (old-buffer-size (buffer-size)))
    ;; If our align regexp is just spaces, then we don't need any
    ;; extra spacing.
    (when (string-match regexp " ")
      (setq spacing 0))
    (align-regexp start stop
                  ;; add space at beginning of regexp
                  (concat "\\([[:space:]]*\\)" regexp)
                  1 spacing t)
    ;; modify stop because align-regexp will add/remove characters
    (align-regexp start (+ stop (- (buffer-size) old-buffer-size))
                  ;; add space at end of regexp
                  (concat regexp "\\([[:space:]]*\\)")
                  1 spacing t)))



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

end of thread, other threads:[~2013-03-18 18:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.22392.1363601736.855.help-gnu-emacs@gnu.org>
2013-03-18 18:39 ` align-regexp not working as intended jpkotta
2013-03-18 10:15 Florian Lindner

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.