From 33d1e2f5bdaca00fa003faab1d3f8b03dec98023 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Wed, 6 Mar 2013 14:24:39 +0000 Subject: [PATCH] Correct the position of point in some line-up functions. progmodes/cc-align.el (c-lineup-whitesmith-in-block, c-lineup-assignments) (c-lineup-gcc-asm-reg ): take position of point at column 0 rather than at a random place in the line. doc/misc/cc-mode.texi (Custom Line-Up): State explicitly that point starts at a random position in the line being indented. --- doc/misc/ChangeLog | 5 +++++ doc/misc/cc-mode.texi | 15 ++++++++------- lisp/ChangeLog | 7 +++++++ lisp/progmodes/cc-align.el | 4 +++- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index 8ffc040d27f..3a3ed4623d1 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog @@ -1,3 +1,8 @@ +2013-03-06 Alan Mackenzie + + * cc-mode.texi (Custom Line-Up): Clarify position of point on + calling a line-up function. + 2013-03-04 Paul Eggert * emacs-mime.texi, htmlfontify.texi, mairix-el.texi, mh-e.texi: diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi index bb6a5b001ad..4fa4e12cf88 100644 --- a/doc/misc/cc-mode.texi +++ b/doc/misc/cc-mode.texi @@ -6475,13 +6475,14 @@ think is generally useful, you're very welcome to contribute it; please contact @email{bug-cc-mode@@gnu.org}. Line-up functions are passed a single argument, the syntactic -element (see below). The return value is a @code{c-offsets-alist} -offset specification: for example, an integer, a symbol such as -@code{+}, a vector, @code{nil}@footnote{Returning @code{nil} is useful -when the offset specification for a syntactic element is a list -containing the line-up function (@pxref{c-offsets-alist}).}, or even -another line-up function. Full details of these are in -@ref{c-offsets-alist}. +element (see below). At the time of the call, point will be somewhere +on the line being indented. The return value is a +@code{c-offsets-alist} offset specification: for example, an integer, +a symbol such as @code{+}, a vector, @code{nil}@footnote{Returning +@code{nil} is useful when the offset specification for a syntactic +element is a list containing the line-up function +(@pxref{c-offsets-alist}).}, or even another line-up function. Full +details of these are in @ref{c-offsets-alist}. Line-up functions must not move point or change the content of the buffer (except temporarily). They are however allowed to do diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ac56cd8ba79..18242539cca 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2013-03-06 Alan Mackenzie + + Correct the position of point in some line-up functions. + * progmodes/cc-align.el (c-lineup-whitesmith-in-block) + (c-lineup-assignments, c-lineup-gcc-asm-reg ): take position of + point at column 0 rather than at a random place in the line. + 2013-03-05 Michael Albinus * net/tramp-compat.el (tramp-compat-delete-directory): Implement diff --git a/lisp/progmodes/cc-align.el b/lisp/progmodes/cc-align.el index cdd0561a054..33836f25335 100644 --- a/lisp/progmodes/cc-align.el +++ b/lisp/progmodes/cc-align.el @@ -737,7 +737,7 @@ arglist-cont-nonempty." (setq startpos (c-langelem-pos langelem))))) (setq startpos (c-langelem-pos langelem) - endpos (point)) + endpos (c-point 'bol)) ;; Find a syntactically relevant and unnested "=" token on the ;; current line. equalp is in that case set to the number of @@ -1039,6 +1039,7 @@ brace-list-close, brace-list-intro, statement-block-intro, arglist-intro, arglist-cont-nonempty, arglist-close, and all in* symbols, e.g. inclass and inextern-lang." (save-excursion + (beginning-of-line) (if (and (c-go-up-list-backward) (= (point) (c-point 'boi))) nil @@ -1191,6 +1192,7 @@ Works with: arglist-cont, arglist-cont-nonempty." (let ((orig-pos (point)) alignto) (save-excursion + (beginning-of-line) (and c-opt-asm-stmt-key -- 2.39.2