unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#16381: 24.3.50; align issue
@ 2014-01-07 10:51 djcb
  2014-06-23 14:24 ` Leo Liu
  0 siblings, 1 reply; 8+ messages in thread
From: djcb @ 2014-01-07 10:51 UTC (permalink / raw)
  To: 16381


When trying this with a simple c-program, it seems the `align' function
has changed behavior since 24.3; it no longer (by default at least)
gives at least one space, and in some cases actually breaks the code by
concatenating the type and variable name. E.g. write some like this
(after emacs -Q test.c)

int foo (int bar)
{
  char flub;
 
}

now mark the 'char flub' line, M-x align and we get:

int foo (int bar)
{
  charflub;
 
}

which gcc doesn't really appreciate. In general it seems that align does
not insert at least one space between type and variable in c-mode.




In GNU Emacs 24.3.50.5 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.6)
 of 2014-01-07 on borealis
Windowing system distributor `Fedora Project', version 11.0.11404000
System Description:	Fedora release 20 (Heisenbug)

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_MESSAGES: en_US.UTF-8
  value of $LC_MONETARY: en_DK.utf8
  value of $LC_NUMERIC: en_DK.utf8
  value of $LC_TIME: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: C/l

Minor modes in effect:
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Recent input:
<down-mouse-1> <mouse-1> i n t SPC f o o SPC ( i n 
t a <backspace> SPC b a r ) <return> { <return> <return> 
{ <backspace> } <up> <up> <return> i n t SPC c u u 
x ; <return> c h a r SPC f l u b ; <return> <backspace> 
<up> <up> C-SPC <down> <down> M-x <up> <up> a l i g 
n <return> <help-echo> <down-mouse-1> <mouse-movement> 
<mouse-movement> <drag-mouse-1> <down-mouse-1> <mouse-1> 
<down-mouse-1> <mouse-movement> <mouse-movement> <drag-mouse-1> 
<down-mouse-1> <mouse-1> <down-mouse-1> <mouse-1> SPC 
<down-mouse-1> <mouse-movement> <mouse-movement> <drag-mouse-1> 
M-w <down-mouse-1> <mouse-movement> <mouse-movement> 
<drag-mouse-1> M-x <up> <return> <down-mouse-1> <drag-mouse-1> 
<down-mouse-1> <mouse-movement> <mouse-movement> <drag-mouse-1> 
<down-mouse-1> <mouse-1> <down-mouse-1> <mouse-movement> 
<mouse-movement> <drag-mouse-1> M-w <down-mouse-1> 
<mouse-1> C-/ <up> <up> <right> C-k C-k <right> <right> 
<right> <right> <right> <right> <up> <right> C-SPC 
<down> <left> M-x <up> <return> <down-mouse-1> <mouse-1> 
C-/ <left> <left> <left> <left> <left> M-x <up> <return> 
<help-echo> <help-echo> <down-mouse-1> <mouse-movement> 
<drag-mouse-1> <up> <up> <up> <right> C-SPC <down> 
<left> <left> <left> <right> <down> M-x <up> <return> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <menu-bar> <help-menu> <send-emacs-bug
-report>

Recent messages:
Mark set
user-error: Beginning of history; no preceding item [2 times]
Auto-saving...done
Auto-saving...done
<left-fringe> <drag-mouse-1> is undefined
Undo!
Mark set
Undo!
Mark set [2 times]
Auto-saving...done

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message cl-macs gv format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util help-fns mail-prsvr mail-utils align vc-git cc-langs cl
cl-loaddefs cl-lib cc-mode cc-fonts easymenu cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs time-date tooltip electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)





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

* bug#16381: 24.3.50; align issue
  2014-01-07 10:51 bug#16381: 24.3.50; align issue djcb
@ 2014-06-23 14:24 ` Leo Liu
  2014-06-23 15:38   ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Leo Liu @ 2014-06-23 14:24 UTC (permalink / raw)
  To: djcb; +Cc: 16381

On 2014-01-07 12:51 +0200, djcb@djcbsoftware.nl wrote:
> int foo (int bar)
> {
>   char flub;
>  
> }
>
> now mark the 'char flub' line, M-x align and we get:
>
> int foo (int bar)
> {
>   charflub;
>  
> }

This is broken by defaulting tab-stop-list to nil in revno: 114577.
Stefan, can I fix it as follows in emacs-24? Thanks, Leo.

=== modified file 'lisp/align.el'
--- lisp/align.el	2014-03-24 16:54:24 +0000
+++ lisp/align.el	2014-06-23 14:22:10 +0000
@@ -1130,13 +1130,8 @@
       column
     (if (not tab-stop)
 	(+ column spacing)
-      (let ((stops tab-stop-list))
-	(while stops
-	  (if (and (> (car stops) column)
-		   (= (setq spacing (1- spacing)) 0))
-	      (setq column (car stops)
-		    stops nil)
-	    (setq stops (cdr stops)))))
+      (dotimes (_ spacing)
+	(setq column (indent-next-tab-stop column)))
       column)))
 
 (defsubst align-column (pos)

=== modified file 'lisp/indent.el'
--- lisp/indent.el	2014-02-10 01:34:22 +0000
+++ lisp/indent.el	2014-06-23 12:43:33 +0000
@@ -249,7 +249,7 @@
   (indent-rigidly--pop-undo)
   (let* ((current (indent-rigidly--current-indentation beg end))
 	 (rtl (eq (current-bidi-paragraph-direction) 'right-to-left))
-	 (next (indent--next-tab-stop current (if rtl nil 'prev))))
+	 (next (indent-next-tab-stop current (if rtl nil 'prev))))
     (indent-rigidly beg end (- next current))))
 
 (defun indent-rigidly-right-to-tab-stop (beg end)
@@ -258,7 +258,7 @@
   (indent-rigidly--pop-undo)
   (let* ((current (indent-rigidly--current-indentation beg end))
 	 (rtl (eq (current-bidi-paragraph-direction) 'right-to-left))
-	 (next (indent--next-tab-stop current (if rtl 'prev))))
+	 (next (indent-next-tab-stop current (if rtl 'prev))))
     (indent-rigidly beg end (- next current))))
 
 (defun indent-line-to (column)
@@ -654,7 +654,7 @@
       (setq tab-stop-list tabs))
   (message "Tab stops installed"))
 
-(defun indent--next-tab-stop (column &optional prev)
+(defun indent-next-tab-stop (column &optional prev)
   "Return the next tab stop after COLUMN.
 If PREV is non-nil, return the previous one instead."
   (let ((tabs tab-stop-list))
@@ -684,7 +684,7 @@
   (interactive)
   (and abbrev-mode (= (char-syntax (preceding-char)) ?w)
        (expand-abbrev))
-  (let ((nexttab (indent--next-tab-stop (current-column))))
+  (let ((nexttab (indent-next-tab-stop (current-column))))
     (delete-horizontal-space t)
     (indent-to nexttab)))
 
@@ -693,7 +693,7 @@
 The variable `tab-stop-list' is a list of columns at which there are tab stops.
 Use \\[edit-tab-stops] to edit them interactively."
   (interactive)
-  (let ((nexttab (indent--next-tab-stop (current-column))))
+  (let ((nexttab (indent-next-tab-stop (current-column))))
     (let ((before (point)))
       (move-to-column nexttab t)
       (save-excursion





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

* bug#16381: 24.3.50; align issue
  2014-06-23 14:24 ` Leo Liu
@ 2014-06-23 15:38   ` Stefan Monnier
  2014-06-23 23:15     ` Leo Liu
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2014-06-23 15:38 UTC (permalink / raw)
  To: Leo Liu; +Cc: 16381, djcb

> This is broken by defaulting tab-stop-list to nil in revno: 114577.
> Stefan, can I fix it as follows in emacs-24? Thanks, Leo.

Hmm... I guess it's OK, yes.  Thanks,


        Stefan





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

* bug#16381: 24.3.50; align issue
  2014-06-23 15:38   ` Stefan Monnier
@ 2014-06-23 23:15     ` Leo Liu
  2014-06-24  5:54       ` Glenn Morris
  0 siblings, 1 reply; 8+ messages in thread
From: Leo Liu @ 2014-06-23 23:15 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16381-done, djcb

Fixed in 24.4.

On 2014-06-23 11:38 -0400, Stefan Monnier wrote:
> Hmm... I guess it's OK, yes.

Thanks and done.

Leo





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

* bug#16381: 24.3.50; align issue
  2014-06-23 23:15     ` Leo Liu
@ 2014-06-24  5:54       ` Glenn Morris
  2014-06-24 13:05         ` Leo Liu
  0 siblings, 1 reply; 8+ messages in thread
From: Glenn Morris @ 2014-06-24  5:54 UTC (permalink / raw)
  To: 16381; +Cc: sdl.web


I think there is a smilar issue with ruler-mode. Compare:

emacs -Q --eval '(setq ruler-mode-show-tab-stops t)' -f ruler-mode

in 24.3 (tabs marked) and 24.3.91 (no tabs marked).

Leo, any chance you could fix that one too?

There are a handful of other files that use tab-stop-list;
it would be good to check them too.





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

* bug#16381: 24.3.50; align issue
  2014-06-24  5:54       ` Glenn Morris
@ 2014-06-24 13:05         ` Leo Liu
  2014-06-25 17:30           ` Glenn Morris
  0 siblings, 1 reply; 8+ messages in thread
From: Leo Liu @ 2014-06-24 13:05 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 16381

On 2014-06-24 01:54 -0400, Glenn Morris wrote:
> Leo, any chance you could fix that one too?
>
> There are a handful of other files that use tab-stop-list;
> it would be good to check them too.

I did a grep in lisp/ and these are the files using tab-stop-list:

- woman.el
- progmodes/asm-mode.el
- ruler-mode.el
- textmodes/picture.el

The following patch seems to fix all except woman.el. woman.el seems to
use its own interpretation of tab-stop-list i.e. it may not be affected
at all by the change to tab-stop-list. Comments? Leo

=== modified file 'lisp/indent.el'
--- lisp/indent.el	2014-06-23 23:09:20 +0000
+++ lisp/indent.el	2014-06-24 12:22:40 +0000
@@ -677,6 +677,13 @@
                             (if (<= column last) -1 (/ (- column last 1) step))
                           (1+ (/ (- column last) step)))))))))
 
+(defun indent-accumulate-tab-stops (limit)
+  "Get a list of tab stops before LIMIT (inclusive)."
+  (let ((tab 0) (tab-stops))
+    (while (<= (setq tab (indent-next-tab-stop tab)) limit)
+      (push tab tab-stops))
+    (nreverse tab-stops)))
+
 (defun tab-to-tab-stop ()
   "Insert spaces or tabs to next defined tab-stop column.
 The variable `tab-stop-list' is a list of columns at which there are tab stops.

=== modified file 'lisp/progmodes/asm-mode.el'
--- lisp/progmodes/asm-mode.el	2014-02-10 01:34:22 +0000
+++ lisp/progmodes/asm-mode.el	2014-06-24 12:53:03 +0000
@@ -172,7 +172,7 @@
    ;; Simple `;' comments go to the comment-column.
    (and (looking-at "\\s<\\(\\S<\\|\\'\\)") comment-column)
    ;; The rest goes at the first tab stop.
-   (or (car tab-stop-list) tab-width)))
+   (or (indent-next-tab-stop 0))))
 
 (defun asm-colon ()
   "Insert a colon; if it follows a label, delete the label's indentation."

=== modified file 'lisp/ruler-mode.el'
--- lisp/ruler-mode.el	2014-06-16 06:37:37 +0000
+++ lisp/ruler-mode.el	2014-06-24 12:58:16 +0000
@@ -476,8 +476,11 @@
                (not (member ts tab-stop-list))
                (progn
                  (message "Tab stop set to %d" ts)
-                 (setq tab-stop-list (sort (cons ts tab-stop-list)
-                                           #'<)))))))))
+                 ;; If `tab-stop-list' is empty, populate it with tab
+                 ;; stops before TS.
+                 (when (null tab-stop-list)
+                   (setq tab-stop-list (indent-accumulate-tab-stops (1- ts))))
+                 (setq tab-stop-list (sort (cons ts tab-stop-list) #'<)))))))))
 
 (defun ruler-mode-mouse-del-tab-stop (start-event)
   "Delete tab stop at the graduation where the mouse pointer is on.
@@ -753,7 +756,7 @@
          i (1+ i) 'help-echo ruler-mode-fill-column-help-echo
          ruler))
        ;; Show the `tab-stop-list' markers.
-       ((and ruler-mode-show-tab-stops (member j tab-stop-list))
+       ((and ruler-mode-show-tab-stops (= j (indent-next-tab-stop (1- j))))
         (aset ruler i ruler-mode-tab-stop-char)
         (put-text-property
          i (1+ i) 'face 'ruler-mode-tab-stop

=== modified file 'lisp/textmodes/picture.el'
--- lisp/textmodes/picture.el	2014-02-10 01:34:22 +0000
+++ lisp/textmodes/picture.el	2014-06-24 12:45:46 +0000
@@ -418,7 +418,8 @@
   (save-excursion
     (let (tabs)
       (if arg
-	  (setq tabs (default-value 'tab-stop-list))
+	  (setq tabs (or (default-value 'tab-stop-list)
+			 (indent-accumulate-tab-stops (window-width))))
 	(let ((regexp (concat "[ \t]+[" (regexp-quote picture-tab-chars) "]")))
 	  (beginning-of-line)
 	  (let ((bol (point)))





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

* bug#16381: 24.3.50; align issue
  2014-06-24 13:05         ` Leo Liu
@ 2014-06-25 17:30           ` Glenn Morris
  2014-06-25 23:56             ` Leo Liu
  0 siblings, 1 reply; 8+ messages in thread
From: Glenn Morris @ 2014-06-25 17:30 UTC (permalink / raw)
  To: Leo Liu; +Cc: 16381


I didn't test it, but it looks ok to me. Thanks.






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

* bug#16381: 24.3.50; align issue
  2014-06-25 17:30           ` Glenn Morris
@ 2014-06-25 23:56             ` Leo Liu
  0 siblings, 0 replies; 8+ messages in thread
From: Leo Liu @ 2014-06-25 23:56 UTC (permalink / raw)
  To: 16381

On 2014-06-25 13:30 -0400, Glenn Morris wrote:
> I didn't test it, but it looks ok to me. Thanks.

Thanks and installed in emacs-24 branch.

Leo






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

end of thread, other threads:[~2014-06-25 23:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-07 10:51 bug#16381: 24.3.50; align issue djcb
2014-06-23 14:24 ` Leo Liu
2014-06-23 15:38   ` Stefan Monnier
2014-06-23 23:15     ` Leo Liu
2014-06-24  5:54       ` Glenn Morris
2014-06-24 13:05         ` Leo Liu
2014-06-25 17:30           ` Glenn Morris
2014-06-25 23:56             ` Leo Liu

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).