From 01db225d1c53f3d2056f4521ce14a2f499258d06 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Thu, 27 Oct 2011 06:22:00 -0400 Subject: [PATCH 01/18] Auto-commit of loaddefs files. --- lisp/emacs-lisp/cl-loaddefs.el | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lisp/emacs-lisp/cl-loaddefs.el b/lisp/emacs-lisp/cl-loaddefs.el index d6512306ad1..1cd953d9e18 100644 --- a/lisp/emacs-lisp/cl-loaddefs.el +++ b/lisp/emacs-lisp/cl-loaddefs.el @@ -10,7 +10,7 @@ ;;;;;; ceiling* floor* isqrt lcm gcd cl-progv-before cl-set-frame-visible-p ;;;;;; cl-map-overlays cl-map-intervals cl-map-keymap-recursively ;;;;;; notevery notany every some mapcon mapcan mapl maplist map -;;;;;; cl-mapcar-many equalp coerce) "cl-extra" "cl-extra.el" "26339d9571f9485bf34fa6d2ae38fc84") +;;;;;; cl-mapcar-many equalp coerce) "cl-extra" "cl-extra.el" "15a5e127e1c9c9c3d1f398963b66cde7") ;;; Generated autoloads from cl-extra.el (autoload 'coerce "cl-extra" "\ @@ -28,7 +28,7 @@ strings case-insensitively. \(fn X Y)" nil nil) (autoload 'cl-mapcar-many "cl-extra" "\ -Not documented + \(fn CL-FUNC CL-SEQS)" nil nil) @@ -84,27 +84,27 @@ Return true if PREDICATE is false of some element of SEQ or SEQs. (defalias 'cl-map-keymap 'map-keymap) (autoload 'cl-map-keymap-recursively "cl-extra" "\ -Not documented + \(fn CL-FUNC-REC CL-MAP &optional CL-BASE)" nil nil) (autoload 'cl-map-intervals "cl-extra" "\ -Not documented + \(fn CL-FUNC &optional CL-WHAT CL-PROP CL-START CL-END)" nil nil) (autoload 'cl-map-overlays "cl-extra" "\ -Not documented + \(fn CL-FUNC &optional CL-BUFFER CL-START CL-END CL-ARG)" nil nil) (autoload 'cl-set-frame-visible-p "cl-extra" "\ -Not documented + \(fn FRAME VAL)" nil nil) (autoload 'cl-progv-before "cl-extra" "\ -Not documented + \(fn SYMS VALUES)" nil nil) @@ -180,7 +180,11 @@ Return t if OBJECT is a random-state object. \(fn OBJECT)" nil nil) (autoload 'cl-float-limits "cl-extra" "\ -Not documented +Initialize the Common Lisp floating-point parameters. +This sets the values of: `most-positive-float', `most-negative-float', +`least-positive-float', `least-negative-float', `float-epsilon', +`float-negative-epsilon', `least-positive-normalized-float', and +`least-negative-normalized-float'. \(fn)" nil nil) @@ -228,12 +232,12 @@ PROPLIST is a list of the sort returned by `symbol-plist'. \(fn PROPLIST PROPNAME &optional DEFAULT)" nil nil) (autoload 'cl-set-getf "cl-extra" "\ -Not documented + \(fn PLIST TAG VAL)" nil nil) (autoload 'cl-do-remf "cl-extra" "\ -Not documented + \(fn PLIST TAG)" nil nil) @@ -267,7 +271,7 @@ This also does some trivial optimizations to make the form prettier. \(fn FORM &optional ENV)" nil nil) (autoload 'cl-prettyexpand "cl-extra" "\ -Not documented + \(fn FORM &optional FULL)" nil nil) From 87e68db4734d89bab693744ad210560da0c20a87 Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Thu, 27 Oct 2011 16:35:51 +0200 Subject: [PATCH 02/18] src/window.c: Fix typos in docstrings. --- src/ChangeLog | 7 +++++++ src/window.c | 40 ++++++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index c3926f6024b..0d421223228 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2011-10-27 Juanma Barranquero + + * window.c (Fframe_root_window, Fframe_first_window, Fwindow_end) + (Fframe_selected_window, Ftemp_output_buffer_show, Fnext_window) + (Fdelete_window_internal, Fwindow_parameters): Fix typos in docstrings. + (Fmove_to_window_line): Doc fix. + 2011-10-27 Chong Yidong * process.c (make_process): Set gnutls_state to NULL. diff --git a/src/window.c b/src/window.c index c3b4384137d..0c35b913789 100644 --- a/src/window.c +++ b/src/window.c @@ -175,10 +175,10 @@ WINDOW can be any window and defaults to the selected one. */) } DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0, - doc: /* Return the root window of FRAME_OR_WINDOW. -If omitted, FRAME_OR_WINDOW defaults to the currently selected frame. -Else if FRAME_OR_WINDOW denotes any window, return the root window of -that window's frame. If FRAME_OR_WINDOW denotes a live frame, return + doc: /* Return the root window of FRAME-OR-WINDOW. +If omitted, FRAME-OR-WINDOW defaults to the currently selected frame. +Else if FRAME-OR-WINDOW denotes any window, return the root window of +that window's frame. If FRAME-OR-WINDOW denotes a live frame, return the root window of that frame. */) (Lisp_Object frame_or_window) { @@ -220,10 +220,10 @@ WINDOW can be any window and defaults to the selected one. */) /* Don't move this to window.el - this must be a safe routine. */ DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0, - doc: /* Return the topmost, leftmost live window on FRAME_OR_WINDOW. -If omitted, FRAME_OR_WINDOW defaults to the currently selected frame. -Else if FRAME_OR_WINDOW denotes any window, return the first window of -that window's frame. If FRAME_OR_WINDOW denotes a live frame, return + doc: /* Return the topmost, leftmost live window on FRAME-OR-WINDOW. +If omitted, FRAME-OR-WINDOW defaults to the currently selected frame. +Else if FRAME-OR-WINDOW denotes any window, return the first window of +that window's frame. If FRAME-OR-WINDOW denotes a live frame, return the first window of that frame. */) (Lisp_Object frame_or_window) { @@ -254,10 +254,10 @@ the first window of that frame. */) DEFUN ("frame-selected-window", Fframe_selected_window, Sframe_selected_window, 0, 1, 0, - doc: /* Return the selected window of FRAME_OR_WINDOW. -If omitted, FRAME_OR_WINDOW defaults to the currently selected frame. -Else if FRAME_OR_WINDOW denotes any window, return the selected window -of that window's frame. If FRAME_OR_WINDOW denotes a live frame, return + doc: /* Return the selected window of FRAME-OR-WINDOW. +If omitted, FRAME-OR-WINDOW defaults to the currently selected frame. +Else if FRAME-OR-WINDOW denotes any window, return the selected window +of that window's frame. If FRAME-OR-WINDOW denotes a live frame, return the selected window of that frame. */) (Lisp_Object frame_or_window) { @@ -1297,7 +1297,7 @@ WINDOW must be a live window and defaults to the selected one. This is updated by redisplay, when it runs to completion. Simply changing the buffer text or setting `window-start' does not update this value. -Return nil if there is no recorded value. \(This can happen if the +Return nil if there is no recorded value. (This can happen if the last redisplay of WINDOW was preempted, and did not finish.) If UPDATE is non-nil, compute the up-to-date position if it isn't already recorded. */) @@ -1688,7 +1688,7 @@ DEFUN ("window-parameters", Fwindow_parameters, Swindow_parameters, 0, 1, 0, doc: /* Return the parameters of WINDOW and their values. WINDOW defaults to the selected window. The return value is a list of -elements of the form (PARAMETER . VALUE). */) +elements of the form (PARAMETER . VALUE). */) (Lisp_Object window) { return Fcopy_alist (decode_any_window (window)->window_parameters); @@ -2193,7 +2193,7 @@ next_window (Lisp_Object window, Lisp_Object minibuf, Lisp_Object all_frames, in DEFUN ("next-window", Fnext_window, Snext_window, 0, 3, 0, doc: /* Return window following WINDOW in cyclic ordering of windows. -WINDOW must be a live window and defaults to the selected one. The +WINDOW must be a live window and defaults to the selected one. The optional arguments MINIBUF and ALL-FRAMES specify the set of windows to consider. @@ -3224,7 +3224,7 @@ temp_output_buffer_show (register Lisp_Object buf) DEFUN ("internal-temp-output-buffer-show", Ftemp_output_buffer_show, Stemp_output_buffer_show, 1, 1, 0, - doc: /* Internal function for `with-output-to-temp-buffer''. */) + doc: /* Internal function for `with-output-to-temp-buffer'. */) (Lisp_Object buf) { temp_output_buffer_show (buf); @@ -3845,8 +3845,8 @@ set correctly. See the code of `split-window' for how this is done. */) DEFUN ("delete-window-internal", Fdelete_window_internal, Sdelete_window_internal, 1, 1, 0, doc: /* Remove WINDOW from its frame. -WINDOW defaults to the selected window. Return nil. Signal an error -when WINDOW is the only window on its frame. */) +WINDOW defaults to the selected window. Return nil. +Signal an error when WINDOW is the only window on its frame. */) (register Lisp_Object window) { register Lisp_Object parent, sibling, frame, root; @@ -5225,8 +5225,8 @@ any partial-height lines in the text display area. */) DEFUN ("move-to-window-line", Fmove_to_window_line, Smove_to_window_line, 1, 1, "P", doc: /* Position point relative to window. -With no argument, position point at center of window. -An argument specifies vertical position within the window; +ARG nil means position point at center of window. +Else, ARG specifies vertical position within the window; zero means top of window, negative means relative to bottom of window. */) (Lisp_Object arg) { From 44b0122fbb0af5606471d9667ce6352696d259b8 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Thu, 27 Oct 2011 15:38:35 -0400 Subject: [PATCH 03/18] * lisp/emacs-lisp/cl.el (most-negative-float): Fix doc typo. --- lisp/emacs-lisp/cl.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el index 0b34e9f27f7..16eb31c1209 100644 --- a/lisp/emacs-lisp/cl.el +++ b/lisp/emacs-lisp/cl.el @@ -341,7 +341,7 @@ Call `cl-float-limits' to set this.") (defconst most-negative-float nil "The largest negative value that a Lisp float can hold. -This is simply -`most-negative-float'. +This is simply -`most-positive-float'. Call `cl-float-limits' to set this.") (defconst least-positive-float nil From 536610a433e6edc0b3f831272c4e0424ebebee46 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Thu, 27 Oct 2011 20:34:23 +0000 Subject: [PATCH 04/18] Amend to indent and fontify macros "which include their own semicolon" correctly, using the "virtual semicolon" mechanism. cc-defs.el: Update "virtual semicolon" comments. cc-engine.el (c-crosses-statement-barrier-p): Recoded to scan one line at at time rather than having \n and \r explicitly in c-stmt-delim-chars (for some modes, e.g. AWK). (c-forward-label): Amend for virtual semicolons. (c-at-macro-vsemi-p, c-macro-vsemi-status-unknown-p): New functions cc-fonts.el (c-font-lock-declarations): Take account of the new C macros. cc-langs.el (c-at-vsemi-p-fn, c-vsemi-status-unknown-p-fn): move to earlier in the file. (c-opt-cpp-symbol, c-line-comment-start-regexp): New language variables. (c-opt-cpp-macro-define): Make into a full language variable. (c-stmt-delim-chars, c-stmt-delim-chars-with-comma): Special value for AWK Mode (including \n, \r) removed, no longer needed. cc-mode.el (c-mode, c++-mode, objc-mode): Invoke c-make-macro-with-semi-re. cc-vars.el (c-macro-with-semi-re, c-macro-names-with-semicolon): New variables. (c-make-macro-with-semi-re): New function cc-mode.texi (Indentation Commands): Mention "macros with semicolons". (Other Special Indentations): Add an xref to "Macros with ;". (Customizing Macros): Add stuff about syntax in macros. Add an xref to "Macros with ;". (Macros with ;): New page. --- doc/misc/cc-mode.texi | 97 +++++++++++++++++++++++ lisp/progmodes/cc-defs.el | 19 ++--- lisp/progmodes/cc-engine.el | 150 +++++++++++++++++++++++++++--------- lisp/progmodes/cc-fonts.el | 8 +- lisp/progmodes/cc-langs.el | 72 ++++++++++------- lisp/progmodes/cc-mode.el | 3 + lisp/progmodes/cc-vars.el | 48 ++++++++++++ 7 files changed, 320 insertions(+), 77 deletions(-) diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi index a9339162666..4cc7f351c2e 100644 --- a/doc/misc/cc-mode.texi +++ b/doc/misc/cc-mode.texi @@ -341,6 +341,11 @@ Line-Up Functions * Comment Line-Up:: * Misc Line-Up:: +Customizing Macros + +* Macro Backslashes:: +* Macros with ;:: + @end detailmenu @end menu @@ -655,6 +660,10 @@ expression, to some statements, or perhaps to whole functions, the syntactic recognition can be wrong. @ccmode{} manages to figure it out correctly most of the time, though. +Some macros, when invoked, ''have their own semicolon''. To get the +next line indented correctly, rather than as a continuation line, +@xref{Macros with ;}. + Reindenting large sections of code can take a long time. When @ccmode{} reindents a region of code, it is essentially equivalent to hitting @key{TAB} on every line of the region. @@ -6550,6 +6559,9 @@ custom line-up function associated with it. @section Other Special Indentations @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +To configure macros which you invoke without a terminating @samp{;}, +see @xref{Macros with ;}. + Here are the remaining odds and ends regarding indentation: @defopt c-label-minimum-indentation @@ -6601,6 +6613,13 @@ functions to this hook, not remove them. @xref{Style Variables}. @cindex preprocessor directives @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +Preprocessor macros in C, C++, and Objective C (introduced by +@code{#define}) have a syntax different from the main language---for +example, a macro declaration is not terminated by a semicolon, and if +it is more than a line long, line breaks in it must be escaped with +backslashes. @ccmode{} has some commands to manipulate these, see +@ref{Macro Backslashes}. + Normally, the lines in a multi-line macro are indented relative to each other as though they were code. You can suppress this behavior by setting the following user option: @@ -6612,6 +6631,28 @@ is @code{nil}, all lines inside macro definitions are analyzed as @code{cpp-macro-cont}. @end defopt +Because a macro can expand into anything at all, near where one is +invoked @ccmode{} can only indent and fontify code heuristically. +Sometimes it gets it wrong. Usually you should try to design your +macros so that they ''look like ordinary code'' when you invoke them. +However, one situation is so common that @ccmode{} handles it +specially: that is when certain macros needn't (or mustn't) be +followed by a @samp{;}. You need to configure @ccmode{} to handle +these macros properly, see @ref{Macros with ;}. + +@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +@menu +* Macro Backslashes:: +* Macros with ;:: +@end menu + +@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +@node Macro Backslashes, Macros with ;, Custom Macros, Custom Macros +@comment node-name, next, previous, up +@section Customizing Macro Backslashes +@cindex #define +@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + @ccmode{} provides some tools to help keep the line continuation backslashes in macros neat and tidy. Their precise action is customized with these variables: @@ -6653,6 +6694,62 @@ get aligned only when you explicitly invoke the command @code{c-backslash-region} (@kbd{C-c C-\}). @end defopt +@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +@node Macros with ;, , Macro Backslashes, Custom Macros +@comment node-name, next, previous, up +@section Macros with semicolons +@cindex macros with semicolons +@comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +Macros which needn't (or mustn't) be followed by a semicolon when you +invoke them, @dfn{macros with semicolons}, are very common. These can +cause @ccmode{} to parse the next line wrongly as a +@code{statement-cont} (@pxref{Function Symbols}) and thus mis-indent +it. + +You can prevent this by specifying which macros have semicolons. It +doesn't matter whether or not such a macro has a parameter list: + +@defopt c-macro-names-with-semicolon +@vindex macro-names-with-semicolon (c-) +This buffer-local variable specifies which macros have semicolons. +After setting its value, you need to call +@code{c-make-macro-with-semi-re} for it to take effect. It should be +set to one of these values: + +@table @asis +@item nil +There are no macros with semicolons. +@item a list of strings +Each string is the name of a macro with a semicolon. Only valid +@code{#define} names are allowed here. For example, to set the +default value, you could write the following into your @file{.emacs}: + +@example +(setq c-macro-names-with-semicolon + '("Q_OBJECT" "Q_PROPERTY" "Q_DECLARE" "Q_ENUMS")) +@end example + +@item a regular expression +This matches each symbol which is a macro with a semicolon. It must +not match any string which isn't a valid @code{#define} name. For +example: + +@example +(setq c-macro-names-with-semicolon + "\\<\\(CLEAN_UP_AND_RETURN\\|Q_[[:upper:]]+\\)\\>") +@end example +@end table +@end defopt + +@defun c-make-macro-with-semi-re +@findex make-macro-with-semi-re (c-) +Call this (non-interactive) function, which sets internal variables, +each time you change the value of +@code{c-macro-names-with-semicolon}. It takes no arguments, and its +return value has no meaning. This function is called by @ccmode{}'s +initialization code. +@end defun + @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @node Odds and Ends, Sample .emacs File, Custom Macros, Top @comment node-name, next, previous, up diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index e5b4d7e35a4..93da6e3e2be 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el @@ -744,19 +744,20 @@ be after it." ;; V i r t u a l S e m i c o l o n s ;; ;; In most CC Mode languages, statements are terminated explicitly by -;; semicolons or closing braces. In some of the CC modes (currently only AWK -;; Mode (April 2004)), statements are (or can be) terminated by EOLs. Such a -;; statement is said to be terminated by a "virtual semicolon" (VS). A -;; statement terminated by an actual semicolon or brace is never considered to -;; have a VS. +;; semicolons or closing braces. In some of the CC modes (currently AWK Mode +;; and certain user-specified #define macros in C, C++, etc. (November 2008)), +;; statements are (or can be) terminated by EOLs. Such a statement is said to +;; be terminated by a "virtual semicolon" (VS). A statement terminated by an +;; actual semicolon or brace is never considered to have a VS. ;; ;; The indentation engine (or whatever) tests for a VS at a specific position ;; by invoking the macro `c-at-vsemi-p', which in its turn calls the mode ;; specific function (if any) which is the value of the language variable -;; `c-at-vsemi-p-fn'. The actual details of what constitutes a VS in a -;; language are thus encapsulated in code specific to that language -;; (e.g. cc-awk.el). `c-at-vsemi-p' returns non-nil if point (or the optional -;; parameter POS) is at a VS, nil otherwise. +;; `c-at-vsemi-p-fn'. This function should only use "low-level" features of +;; CC Mode, i.e. features which won't trigger infinite recursion. ;-) The +;; actual details of what constitutes a VS in a language are thus encapsulated +;; in code specific to that language (e.g. cc-awk.el). `c-at-vsemi-p' returns +;; non-nil if point (or the optional parameter POS) is at a VS, nil otherwise. ;; ;; The language specific function might well do extensive analysis of the ;; source text, and may use a cacheing scheme to speed up repeated calls. diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index b2c548847c3..c7e02a1bbd5 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -1149,42 +1149,65 @@ the line. If this virtual semicolon is _at_ from, the function recognizes it. Note that this function might do hidden buffer changes. See the comment at the start of cc-engine.el for more info." - (let ((skip-chars c-stmt-delim-chars) - lit-range) - (save-excursion - (catch 'done - (goto-char from) - (while (progn (skip-chars-forward skip-chars to) - (< (point) to)) - (cond - ((setq lit-range (c-literal-limits from)) ; Have we landed in a string/comment? - (goto-char (cdr lit-range))) - ((eq (char-after) ?:) - (forward-char) - (if (and (eq (char-after) ?:) - (< (point) to)) - ;; Ignore scope operators. - (forward-char) - (setq c-maybe-labelp (1- (point))))) - ((eq (char-after) ??) - ;; A question mark. Can't be a label, so stop - ;; looking for more : and ?. - (setq c-maybe-labelp nil - skip-chars (substring c-stmt-delim-chars 0 -2))) - ((memq (char-after) '(?# ?\n ?\r)) ; A virtual semicolon? - (if (and (eq (char-before) ?\\) (memq (char-after) '(?\n ?\r))) - (backward-char)) - (skip-chars-backward " \t" from) - (if (c-at-vsemi-p) - (throw 'done (point)) - (forward-line))) - (t (throw 'done (point))))) - ;; In trailing space after an as yet undetected virtual semicolon? - (c-backward-syntactic-ws from) - (if (and (< (point) to) - (c-at-vsemi-p)) - (point) - nil))))) + (let* ((skip-chars + ;; If the current language has CPP macros, insert # into skip-chars. + (if c-opt-cpp-symbol + (concat (substring c-stmt-delim-chars 0 1) ; "^" + c-opt-cpp-symbol ; usually "#" + (substring c-stmt-delim-chars 1)) ; e.g. ";{}?:" + c-stmt-delim-chars)) + (non-skip-list + (append (substring skip-chars 1) nil)) ; e.g. (?# ?\; ?{ ?} ?? ?:) + lit-range vsemi-pos) + (save-restriction + (widen) + (save-excursion + (catch 'done + (goto-char from) + (while (progn (skip-chars-forward + skip-chars + (min to (c-point 'bonl))) + (< (point) to)) + (cond + ;; Virtual semicolon? + ((and (bolp) + (save-excursion + (progn + (if (setq lit-range (c-literal-limits from)) ; Have we landed in a string/comment? + (goto-char (car lit-range))) + (c-backward-syntactic-ws) ; ? put a limit here, maybe? + (setq vsemi-pos (point)) + (c-at-vsemi-p)))) + (throw 'done vsemi-pos)) + ;; In a string/comment? + ((setq lit-range (c-literal-limits)) + (goto-char (cdr lit-range))) + ((eq (char-after) ?:) + (forward-char) + (if (and (eq (char-after) ?:) + (< (point) to)) + ;; Ignore scope operators. + (forward-char) + (setq c-maybe-labelp (1- (point))))) + ((eq (char-after) ??) + ;; A question mark. Can't be a label, so stop + ;; looking for more : and ?. + (setq c-maybe-labelp nil + skip-chars (substring c-stmt-delim-chars 0 -2))) + ;; At a CPP construct? + ((and c-opt-cpp-symbol (looking-at c-opt-cpp-symbol) + (save-excursion + (forward-line 0) + (looking-at c-opt-cpp-prefix))) + (c-end-of-macro)) + ((memq (char-after) non-skip-list) + (throw 'done (point))))) + ;; In trailing space after an as yet undetected virtual semicolon? + (c-backward-syntactic-ws from) + (if (and (< (point) to) + (c-at-vsemi-p)) + (point) + nil)))))) (defun c-at-statement-start-p () "Return non-nil if the point is at the first token in a statement @@ -7158,12 +7181,14 @@ comment at the start of cc-engine.el for more info." ;; Check that we're not after a token that can't precede a label. (or ;; Trivially succeeds when there's no preceding token. + ;; Succeeds when we're at a virtual semicolon. (if preceding-token-end (<= preceding-token-end (point-min)) (save-excursion (c-backward-syntactic-ws) (setq preceding-token-end (point)) - (bobp))) + (or (bobp) + (c-at-vsemi-p)))) ;; Check if we're after a label, if we're after a closing ;; paren that belong to statement, and with @@ -8372,6 +8397,57 @@ comment at the start of cc-engine.el for more info." paren-state) containing-sexp))))) +(defun c-at-macro-vsemi-p (&optional pos) + ;; Is there a "virtual semicolon" at POS or point? + ;; (See cc-defs.el for full details of "virtual semicolons".) + ;; + ;; This is true when point is at the last non syntactic WS position on the + ;; line, there is a macro call last on the line, and this particular macro's + ;; name is defined by the regexp `c-vs-macro-regexp' as not needing a + ;; semicolon. + (save-excursion + (save-restriction + (widen) + (if pos + (goto-char pos) + (setq pos (point))) + (and + c-macro-with-semi-re + (not (c-in-literal)) + (eq (skip-chars-backward " \t") 0) + + ;; Check we've got nothing after this except comments and empty lines + ;; joined by escaped EOLs. + (skip-chars-forward " \t") ; always returns non-nil. + (progn + (while ; go over 1 block comment per iteration. + (and + (looking-at "\\(\\\\[\n\r][ \t]*\\)*") + (goto-char (match-end 0)) + (cond + ((looking-at c-block-comment-start-regexp) + (and (forward-comment 1) + (skip-chars-forward " \t"))) ; always returns non-nil + ((looking-at c-line-comment-start-regexp) + (end-of-line) + nil) + (t nil)))) + (eolp)) + + (goto-char pos) + (progn (c-backward-syntactic-ws) + (eq (point) pos)) + + ;; Check for one of the listed macros being before point. + (or (not (eq (char-before) ?\))) + (when (c-go-list-backward) + (c-backward-syntactic-ws) + t)) + (c-simple-skip-symbol-backward) + (looking-at c-macro-with-semi-re))))) + +(defun c-macro-vsemi-status-unknown-p () t) ; See cc-defs.el. + ;; `c-guess-basic-syntax' and the functions that precedes it below ;; implements the main decision tree for determining the syntactic diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index fd817e3b4f4..9a83d5196db 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el @@ -1277,9 +1277,11 @@ casts and declarations are fontified. Used on level 2 and higher." (when ;; The result of the form below is true when we don't recognize a ;; declaration or cast. - (if (and (eq (get-text-property (point) 'face) - 'font-lock-keyword-face) - (looking-at c-not-decl-init-keywords)) + (if (or (and (eq (get-text-property (point) 'face) + 'font-lock-keyword-face) + (looking-at c-not-decl-init-keywords)) + (and c-macro-with-semi-re + (looking-at c-macro-with-semi-re))) ; 2008-11-04 ;; Don't do anything more if we're looking at a keyword that ;; can't start a declaration. t diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 279c5e46c46..09f8b318378 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el @@ -508,6 +508,31 @@ parameters \(point-min), \(point-max) and ." (c-lang-defvar c-before-font-lock-function (c-lang-const c-before-font-lock-function)) + +;;; Syntactic analysis ("virtual semicolons") for line-oriented languages (AWK). +(c-lang-defconst c-at-vsemi-p-fn + "Contains a function \"Is there a virtual semicolon at POS or point?\". +Such a function takes one optional parameter, a buffer position (defaults to +point), and returns nil or t. This variable contains nil for languages which +don't have EOL terminated statements. " + t nil + (c c++ objc) 'c-at-macro-vsemi-p + awk 'c-awk-at-vsemi-p) +(c-lang-defvar c-at-vsemi-p-fn (c-lang-const c-at-vsemi-p-fn)) + +(c-lang-defconst c-vsemi-status-unknown-p-fn + "Contains a function \"are we unsure whether there is a virtual semicolon on this line?\". +The (admittedly kludgey) purpose of such a function is to prevent an infinite +recursion in c-beginning-of-statement-1 when point starts at a `while' token. +The function MUST NOT UNDER ANY CIRCUMSTANCES call c-beginning-of-statement-1, +even indirectly. This variable contains nil for languages which don't have +EOL terminated statements." + t nil + (c c++ objc) 'c-macro-vsemi-status-unknown-p + awk 'c-awk-vsemi-status-unknown-p) +(c-lang-defvar c-vsemi-status-unknown-p-fn + (c-lang-const c-vsemi-status-unknown-p-fn)) + ;;; Lexer-level syntax (identifiers, tokens etc). @@ -737,6 +762,12 @@ literal are multiline." (c-lang-defvar c-multiline-string-start-char (c-lang-const c-multiline-string-start-char)) +(c-lang-defconst c-opt-cpp-symbol + "The symbol which starts preprocessor constructs when in the margin." + t "#" + (java awk) nil) +(c-lang-defvar c-opt-cpp-symbol (c-lang-const c-opt-cpp-symbol)) + (c-lang-defconst c-opt-cpp-prefix "Regexp matching the prefix of a cpp directive in the languages that normally use that macro preprocessor. Tested at bol or at boi. @@ -785,6 +816,8 @@ file name in angle brackets or quotes." definition, or nil if the language doesn't have any." t (if (c-lang-const c-opt-cpp-prefix) "define")) +(c-lang-defvar c-opt-cpp-macro-define + (c-lang-const c-opt-cpp-macro-define)) (c-lang-defconst c-opt-cpp-macro-define-start ;; Regexp matching everything up to the macro body of a cpp define, or the @@ -1171,14 +1204,12 @@ operators." ;; optimize `c-crosses-statement-barrier-p' somewhat, it's assumed to ;; begin with "^" to negate the set. If ? : operators should be ;; detected then the string must end with "?:". - t "^;{}?:" - awk "^;{}#\n\r?:") ; The newline chars gets special treatment. + t "^;{}?:") (c-lang-defvar c-stmt-delim-chars (c-lang-const c-stmt-delim-chars)) (c-lang-defconst c-stmt-delim-chars-with-comma ;; Variant of `c-stmt-delim-chars' that additionally contains ','. - t "^;,{}?:" - awk "^;,{}\n\r?:") ; The newline chars gets special treatment. + t "^;,{}?:") (c-lang-defvar c-stmt-delim-chars-with-comma (c-lang-const c-stmt-delim-chars-with-comma)) @@ -1238,7 +1269,6 @@ properly." re))) (c-lang-defvar c-comment-start-regexp (c-lang-const c-comment-start-regexp)) -;;;; Added by ACM, 2003/9/18. (c-lang-defconst c-block-comment-start-regexp ;; Regexp which matches the start of a block comment (if such exists in the ;; language) @@ -1248,6 +1278,15 @@ properly." (c-lang-defvar c-block-comment-start-regexp (c-lang-const c-block-comment-start-regexp)) +(c-lang-defconst c-line-comment-start-regexp + ;; Regexp which matches the start of a line comment (if such exists in the + ;; language; it does in all 7 CC Mode languages). + t (if (c-lang-const c-line-comment-starter) + (regexp-quote (c-lang-const c-line-comment-starter)) + "\\<\\>")) +(c-lang-defvar c-line-comment-start-regexp + (c-lang-const c-line-comment-start-regexp)) + (c-lang-defconst c-literal-start-regexp ;; Regexp to match the start of comments and string literals. t (concat (c-lang-const c-comment-start-regexp) @@ -1474,29 +1513,6 @@ properly." "\\)")) (c-lang-defvar c-syntactic-eol (c-lang-const c-syntactic-eol)) - -;;; Syntactic analysis ("virtual semicolons") for line-oriented languages (AWK). -(c-lang-defconst c-at-vsemi-p-fn - "Contains a function \"Is there a virtual semicolon at POS or point?\". -Such a function takes one optional parameter, a buffer position (defaults to -point), and returns nil or t. This variable contains nil for languages which -don't have EOL terminated statements. " - t nil - awk 'c-awk-at-vsemi-p) -(c-lang-defvar c-at-vsemi-p-fn (c-lang-const c-at-vsemi-p-fn)) - -(c-lang-defconst c-vsemi-status-unknown-p-fn - "Contains a function \"are we unsure whether there is a virtual semicolon on this line?\". -The (admittedly kludgey) purpose of such a function is to prevent an infinite -recursion in c-beginning-of-statement-1 when point starts at a `while' token. -The function MUST NOT UNDER ANY CIRCUMSTANCES call c-beginning-of-statement-1, -even indirectly. This variable contains nil for languages which don't have -EOL terminated statements." - t nil - awk 'c-awk-vsemi-status-unknown-p) -(c-lang-defvar c-vsemi-status-unknown-p-fn - (c-lang-const c-vsemi-status-unknown-p-fn)) - ;;; Defun functions diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index eec63b4fa3b..a6bf241f0db 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -1187,6 +1187,7 @@ Key bindings: abbrev-mode t) (use-local-map c-mode-map) (c-init-language-vars-for 'c-mode) + (c-make-macro-with-semi-re) ; matches macro names whose expansion ends with ; (c-common-init 'c-mode) (easy-menu-add c-c-menu) (cc-imenu-init cc-imenu-c-generic-expression) @@ -1246,6 +1247,7 @@ Key bindings: abbrev-mode t) (use-local-map c++-mode-map) (c-init-language-vars-for 'c++-mode) + (c-make-macro-with-semi-re) ; matches macro names whose expansion ends with ; (c-common-init 'c++-mode) (easy-menu-add c-c++-menu) (cc-imenu-init cc-imenu-c++-generic-expression) @@ -1303,6 +1305,7 @@ Key bindings: abbrev-mode t) (use-local-map objc-mode-map) (c-init-language-vars-for 'objc-mode) + (c-make-macro-with-semi-re) ; matches macro names whose expansion ends with ; (c-common-init 'objc-mode) (easy-menu-add c-objc-menu) (cc-imenu-init nil 'cc-imenu-objc-function) diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el index 58dc1737c5a..055d5f4c57c 100644 --- a/lisp/progmodes/cc-vars.el +++ b/lisp/progmodes/cc-vars.el @@ -1608,6 +1608,54 @@ names).")) ;; Non-customizable variables, still part of the interface to CC Mode +(defvar c-macro-with-semi-re nil + ;; Regular expression which matches a (#define'd) symbol whose expansion + ;; ends with a semicolon. + ;; + ;; This variable should be set by `c-make-macros-with-semi-re' rather than + ;; directly. +) +(make-variable-buffer-local 'c-macro-with-semi-re) + +(defun c-make-macro-with-semi-re () + ;; Convert `c-macro-names-with-semicolon' into the regexp + ;; `c-macro-with-semi-re' (or just copy it if it's already a re). + (setq c-macro-with-semi-re + (and + c-opt-cpp-macro-define + (cond + ((stringp c-macro-names-with-semicolon) + (copy-sequence c-macro-names-with-semicolon)) + ((consp c-macro-names-with-semicolon) + (concat + "\\<" + (regexp-opt c-macro-names-with-semicolon) + "\\>")) ; N.B. the PAREN param of regexp-opt isn't supported by + ; all XEmacsen. + ((null c-macro-names-with-semicolon) + nil) + (t (error "c-make-macro-with-semi-re: invalid \ +c-macro-names-with-semicolon: %s" + c-macro-names-with-semicolon)))))) + +(defvar c-macro-names-with-semicolon + '("Q_OBJECT" "Q_PROPERTY" "Q_DECLARE" "Q_ENUMS") + "List of #defined symbols whose expansion ends with a semicolon. +Alternatively it can be a string, a regular expression which +matches all such symbols. + +The \"symbols\" must be syntactically valid identifiers in the +target language \(C, C++, Objective C), or \(as the case may be) +the regular expression must match only valid identifiers. + +If you change this variable's value, call the function +`c-make-macros-with-semi-re' to set the necessary internal +variables. + +Note that currently \(2008-11-04) this variable is a prototype, +and is likely to disappear or change its form soon.") +(make-variable-buffer-local 'c-macro-names-with-semicolon) + (defvar c-file-style nil "Variable interface for setting style via File Local Variables. In a file's Local Variable section, you can set this variable to a From ee1f1da9672772ace63829ed6f83e56eba87f3c5 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 27 Oct 2011 22:22:38 -0400 Subject: [PATCH 05/18] * lisp/progmodes/gdb-mi.el: Warn the user when -i=mi is missing. (gdb--check-interpreter): New function. (gdb): Use it. --- lisp/ChangeLog | 10 ++++++++-- lisp/progmodes/gdb-mi.el | 42 ++++++++++++++++++++++++++-------------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6aa1bddb9f3..98ebed0499d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2011-10-28 Stefan Monnier + + * progmodes/gdb-mi.el: Warn the user when -i=mi is missing. + (gdb--check-interpreter): New function. + (gdb): Use it. + 2011-10-27 Glenn Morris * emacs-lisp/cl-extra.el (most-positive-float, most-negative-float) @@ -21,8 +27,8 @@ * subr.el (change-major-mode-after-body-hook): New hook. (run-mode-hooks): Run it. - * emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Use - change-major-mode-before-body-hook. + * emacs-lisp/easy-mmode.el (define-globalized-minor-mode): + Use change-major-mode-before-body-hook. * simple.el (fundamental-mode): * emacs-lisp/derived.el (define-derived-mode): Revert 2010-04-28 diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 22db7b2e5f4..dde00d753ac 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -43,21 +43,10 @@ ;; M-x gdb will start the debugger. -;; This file uses GDB/MI as the primary interface to GDB. It is still under -;; development and is part of a process to migrate Emacs from annotations (as -;; used in gdb-ui.el) to GDB/MI. It runs gdb with GDB/MI (-interp=mi) and -;; access CLI using "-interpreter-exec console cli-command". This code works -;; without gdb-ui.el and uses MI tokens instead of queues. Eventually MI -;; should be asynchronous. - -;; This mode will PARTLY WORK WITH RECENT GDB RELEASES (status in modeline -;; doesn't update properly when execution commands are issued from GUD buffer) -;; and WORKS BEST when GDB runs asynchronously: maint set linux-async on. -;; -;; You need development version of GDB 7.0 for the thread buffer to work. - -;; This file replaces gdb-ui.el and is for development with GDB. Use the -;; release branch of Emacs 22 for the latest version of gdb-ui.el. +;; This file uses GDB/MI as the primary interface to GDB. It runs gdb with +;; GDB/MI (-interp=mi) and access CLI using "-interpreter-exec console +;; cli-command". This code works without gdb-ui.el and uses MI tokens instead +;; of queues. Eventually MI should be asynchronous. ;; Windows Platforms: @@ -599,6 +588,22 @@ NOARG must be t when this macro is used outside `gud-def'" (concat (gdb-gud-context-command ,cmd1 ,noall) " " ,cmd2) ,(when (not noarg) 'arg))) +(defun gdb--check-interpreter (proc string) + (unless (zerop (length string)) + (let ((filter (process-get proc 'gud-normal-filter))) + (set-process-filter proc filter) + (unless (memq (aref string 0) '(?^ ?~ ?@ ?& ?* ?=)) + ;; Apparently we're not running with -i=mi. + (let ((msg "Error: you did not specify -i=mi on GDB's command line!")) + (message msg) + (setq string (concat (propertize msg 'font-lock-face 'error) + "\n" string))) + ;; Use the old gud-gbd filter, not because it works, but because it + ;; will properly display GDB's answers rather than hanging waiting for + ;; answers that aren't coming. + (set (make-local-variable 'gud-marker-filter) #'gud-gdb-marker-filter)) + (funcall filter proc string)))) + ;;;###autoload (defun gdb (command-line) "Run gdb on program FILE in buffer *gud-FILE*. @@ -665,6 +670,13 @@ detailed description of this mode. "Multiple debugging requires restarting in text command mode")) ;; (gud-common-init command-line nil 'gud-gdbmi-marker-filter) + + ;; Setup a temporary process filter to warn when GDB was not started + ;; with -i=mi. + (let ((proc (get-buffer-process gud-comint-buffer))) + (process-put proc 'gud-normal-filter (process-filter proc)) + (set-process-filter proc #'gdb--check-interpreter)) + (set (make-local-variable 'gud-minor-mode) 'gdbmi) (setq comint-input-sender 'gdb-send) (when (ring-empty-p comint-input-ring) ; cf shell-mode From b0c4cdcf1072b604e8470c634a0b6c0c9a43c1ab Mon Sep 17 00:00:00 2001 From: Mark Lillibridge Date: Thu, 27 Oct 2011 22:47:43 -0400 Subject: [PATCH 06/18] * lisp/mail/rmail.el (rmail-mode-map): Add M-C-f as in rmailsum. Fixes: debbugs:9802 --- lisp/ChangeLog | 4 ++++ lisp/mail/rmail.el | 1 + 2 files changed, 5 insertions(+) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 98ebed0499d..e6e8c2fdb2e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2011-10-28 Mark Lillibridge (tiny change) + + * mail/rmail.el (rmail-mode-map): Add M-C-f as in rmailsum (bug#9802). + 2011-10-28 Stefan Monnier * progmodes/gdb-mi.el: Warn the user when -i=mi is missing. diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 770050efb08..603a615192a 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el @@ -1008,6 +1008,7 @@ The buffer is expected to be narrowed to just the header of the message." (define-key map "\e\C-l" 'rmail-summary-by-labels) (define-key map "\e\C-r" 'rmail-summary-by-recipients) (define-key map "\e\C-s" 'rmail-summary-by-regexp) + (define-key map "\e\C-f" 'rmail-summary-by-senders) (define-key map "\e\C-t" 'rmail-summary-by-topic) (define-key map "m" 'rmail-mail) (define-key map "\em" 'rmail-retry-failure) From 7a6c0941742d41702fb56cd492d4897e476ebc25 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 27 Oct 2011 22:50:05 -0400 Subject: [PATCH 07/18] * lisp/vc/log-edit.el: Fill empty field rather than adding new one. (log-edit-add-field): New function. (log-edit-insert-changelog): Use it. --- lisp/ChangeLog | 6 ++++++ lisp/vc/log-edit.el | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e6e8c2fdb2e..be55e8410bf 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2011-10-28 Stefan Monnier + + * vc/log-edit.el: Fill empty field rather than adding new one. + (log-edit-add-field): New function. + (log-edit-insert-changelog): Use it. + 2011-10-28 Mark Lillibridge (tiny change) * mail/rmail.el (rmail-mode-map): Add M-C-f as in rmailsum (bug#9802). diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el index c421304442f..f57429c76c7 100644 --- a/lisp/vc/log-edit.el +++ b/lisp/vc/log-edit.el @@ -593,6 +593,13 @@ to build the Fixes: header.") (put 'log-edit-rewrite-fixes 'safe-local-variable (lambda (v) (and (stringp (car-safe v)) (stringp (cdr v))))) +(defun log-edit-add-field (field value) + (rfc822-goto-eoh) + (if (save-excursion (re-search-backward (concat "^" field ":\\([ \t]*\\)$") + nil t)) + (replace-match (concat " " value) t t nil 1) + (insert field ": " value "\n" (if (looking-at "\n") "" "\n")))) + (defun log-edit-insert-changelog (&optional use-first) "Insert a log message by looking at the ChangeLog. The idea is to write your ChangeLog entries first, and then use this @@ -620,9 +627,7 @@ regardless of user name or time." (log-edit-insert-changelog-entries (log-edit-files))))) (log-edit-set-common-indentation) ;; Add an Author: field if appropriate. - (when author - (rfc822-goto-eoh) - (insert "Author: " author "\n" (if (looking-at "\n") "" "\n"))) + (when author (log-edit-add-field "Author" author)) ;; Add a Fixes: field if applicable. (when (consp log-edit-rewrite-fixes) (rfc822-goto-eoh) @@ -632,8 +637,7 @@ regardless of user name or time." (fixes (match-substitute-replacement (cdr log-edit-rewrite-fixes)))) (delete-region start end) - (rfc822-goto-eoh) - (insert "Fixes: " fixes "\n" (if (looking-at "\n") "" "\n"))))) + (log-edit-add-field "Fixes" fixes)))) (and log-edit-strip-single-file-name (progn (rfc822-goto-eoh) (if (looking-at "\n") (forward-char 1)) From db4f02f208c551982a54f6ea1fdf3d5577572ca3 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 28 Oct 2011 11:54:02 +0200 Subject: [PATCH 08/18] Fix bug #8562 with Emacs display on Windows 9X. Thanks to oslsachem for helping to debug this. src/w32font.c (g_b_init_is_w9x, g_b_init_get_outline_metrics_w) (g_b_init_get_text_metrics_w, g_b_init_get_glyph_outline_w) (g_b_init_get_glyph_outline_w): New static variables. (GetOutlineTextMetricsW_Proc, GetTextMetricsW_Proc) (GetGlyphOutlineW_Proc): New typedefs. (w32_load_unicows_or_gdi32, get_outline_metrics_w) (get_text_metrics_w, get_glyph_outline_w, globals_of_w32font): New functions. (w32font_open_internal, compute_metrics): Call get_outline_metrics_w, get_text_metrics_w, and get_glyph_outline_w instead of calling the "wide" APIs directly. src/emacs.c (main) [HAVE_NTGUI]: Call globals_of_w32font. src/w32.h (syms_of_w32font): Add prototype. --- src/ChangeLog | 21 +++++++ src/emacs.c | 1 + src/w32.h | 1 + src/w32font.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 168 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 0d421223228..a53c16e9da4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,24 @@ +2011-10-28 Eli Zaretskii + + Fix Emacs on Windows 9X (bug#8562). Thanks to oslsachem + for helping to debug this. + + * w32font.c (g_b_init_is_w9x, g_b_init_get_outline_metrics_w) + (g_b_init_get_text_metrics_w, g_b_init_get_glyph_outline_w) + (g_b_init_get_glyph_outline_w): New static variables. + (GetOutlineTextMetricsW_Proc, GetTextMetricsW_Proc) + (GetGlyphOutlineW_Proc): New typedefs. + (w32_load_unicows_or_gdi32, get_outline_metrics_w) + (get_text_metrics_w, get_glyph_outline_w, globals_of_w32font): New + functions. + (w32font_open_internal, compute_metrics): Call + get_outline_metrics_w, get_text_metrics_w, and get_glyph_outline_w + instead of calling the "wide" APIs directly. + + * emacs.c (main) [HAVE_NTGUI]: Call globals_of_w32font. + + * w32.h (syms_of_w32font): Add prototype. + 2011-10-27 Juanma Barranquero * window.c (Fframe_root_window, Fframe_first_window, Fwindow_end) diff --git a/src/emacs.c b/src/emacs.c index 073156bb0c9..12be7bc0808 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1591,6 +1591,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem /* Initialization that must be done even if the global variable initialized is non zero. */ #ifdef HAVE_NTGUI + globals_of_w32font (); globals_of_w32fns (); globals_of_w32menu (); globals_of_w32select (); diff --git a/src/w32.h b/src/w32.h index f1915125c90..a3ca1130ce6 100644 --- a/src/w32.h +++ b/src/w32.h @@ -139,6 +139,7 @@ extern void term_w32select (void); extern void syms_of_w32menu (void); extern void globals_of_w32menu (void); extern void syms_of_fontset (void); +extern void syms_of_w32font (void); extern int _sys_read_ahead (int fd); extern int _sys_wait_accept (int fd); diff --git a/src/w32font.c b/src/w32font.c index f47b7a46b1e..fb41989caa7 100644 --- a/src/w32font.c +++ b/src/w32font.c @@ -145,6 +145,137 @@ struct font_callback_data style variations if the font name is not specified. */ static void list_all_matching_fonts (struct font_callback_data *); +static BOOL g_b_init_is_w9x; +static BOOL g_b_init_get_outline_metrics_w; +static BOOL g_b_init_get_text_metrics_w; +static BOOL g_b_init_get_glyph_outline_w; +static BOOL g_b_init_get_glyph_outline_w; + +typedef UINT (WINAPI * GetOutlineTextMetricsW_Proc) ( + HDC hdc, + UINT cbData, + LPOUTLINETEXTMETRICW lpotmw); +typedef BOOL (WINAPI * GetTextMetricsW_Proc) ( + HDC hdc, + LPTEXTMETRICW lptmw); +typedef DWORD (WINAPI * GetGlyphOutlineW_Proc) ( + HDC hdc, + UINT uChar, + UINT uFormat, + LPGLYPHMETRICS lpgm, + DWORD cbBuffer, + LPVOID lpvBuffer, + const MAT2 *lpmat2); + +/* Several "wide" functions we use to support the font backends are + unavailable on Windows 9X, unless UNICOWS.DLL is installed (their + versions in the default libraries are non-functional stubs). On NT + and later systems, these functions are in GDI32.DLL. The following + helper function attempts to load UNICOWS.DLL on Windows 9X, and + refuses to let Emacs start up if that library is not found. On NT + and later versions, it simply loads GDI32.DLL, which should always + be available. */ +static HMODULE +w32_load_unicows_or_gdi32 (void) +{ + static BOOL is_9x = 0; + OSVERSIONINFO os_ver; + HMODULE ret; + if (g_b_init_is_w9x == 0) + { + g_b_init_is_w9x = 1; + ZeroMemory (&os_ver, sizeof (OSVERSIONINFO)); + os_ver.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); + if (GetVersionEx (&os_ver)) + is_9x = (os_ver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); + } + if (is_9x) + { + ret = LoadLibrary ("Unicows.dll"); + if (!ret) + { + int button; + + button = MessageBox (NULL, + "Emacs cannot load the UNICOWS.DLL library.\n" + "This library is essential for using Emacs\n" + "on this system. You need to install it.\n\n" + "However, you can still use Emacs by invoking\n" + "it with the '-nw' command-line option.\n\n" + "Emacs will exit when you click OK.", + "Emacs cannot load UNICOWS.DLL", + MB_ICONERROR | MB_TASKMODAL + | MB_SETFOREGROUND | MB_OK); + switch (button) + { + case IDOK: + default: + exit (1); + } + } + } + else + ret = LoadLibrary ("Gdi32.dll"); +} + +/* The following 3 functions call the problematic "wide" APIs via + function pointers, to avoid linking against the non-standard + libunicows on W9X. */ +static UINT WINAPI +get_outline_metrics_w(HDC hdc, UINT cbData, LPOUTLINETEXTMETRICW lpotmw) +{ + static GetOutlineTextMetricsW_Proc s_pfn_Get_Outline_Text_MetricsW = NULL; + HMODULE hm_unicows = NULL; + if (g_b_init_get_outline_metrics_w == 0) + { + g_b_init_get_outline_metrics_w = 1; + hm_unicows = w32_load_unicows_or_gdi32 (); + if (hm_unicows) + s_pfn_Get_Outline_Text_MetricsW = (GetOutlineTextMetricsW_Proc) + GetProcAddress (hm_unicows, "GetOutlineTextMetricsW"); + } + if (s_pfn_Get_Outline_Text_MetricsW == NULL) + abort (); /* cannot happen */ + return s_pfn_Get_Outline_Text_MetricsW (hdc, cbData, lpotmw); +} + +static BOOL WINAPI +get_text_metrics_w(HDC hdc, LPTEXTMETRICW lptmw) +{ + static GetTextMetricsW_Proc s_pfn_Get_Text_MetricsW = NULL; + HMODULE hm_unicows = NULL; + if (g_b_init_get_text_metrics_w == 0) + { + g_b_init_get_text_metrics_w = 1; + hm_unicows = w32_load_unicows_or_gdi32 (); + if (hm_unicows) + s_pfn_Get_Text_MetricsW = (GetTextMetricsW_Proc) + GetProcAddress (hm_unicows, "GetTextMetricsW"); + } + if (s_pfn_Get_Text_MetricsW == NULL) + abort (); /* cannot happen */ + return s_pfn_Get_Text_MetricsW (hdc, lptmw); +} + +static DWORD WINAPI +get_glyph_outline_w (HDC hdc, UINT uChar, UINT uFormat, LPGLYPHMETRICS lpgm, + DWORD cbBuffer, LPVOID lpvBuffer, const MAT2 *lpmat2) +{ + static GetGlyphOutlineW_Proc s_pfn_Get_Glyph_OutlineW = NULL; + HMODULE hm_unicows = NULL; + if (g_b_init_get_glyph_outline_w == 0) + { + g_b_init_get_glyph_outline_w = 1; + hm_unicows = w32_load_unicows_or_gdi32 (); + if (hm_unicows) + s_pfn_Get_Glyph_OutlineW = (GetGlyphOutlineW_Proc) + GetProcAddress (hm_unicows, "GetGlyphOutlineW"); + } + if (s_pfn_Get_Glyph_OutlineW == NULL) + abort (); /* cannot happen */ + return s_pfn_Get_Glyph_OutlineW (hdc, uChar, uFormat, lpgm, cbBuffer, + lpvBuffer, lpmat2); +} static int memq_no_quit (Lisp_Object elt, Lisp_Object list) @@ -816,11 +947,11 @@ w32font_open_internal (FRAME_PTR f, Lisp_Object font_entity, old_font = SelectObject (dc, hfont); /* Try getting the outline metrics (only works for truetype fonts). */ - len = GetOutlineTextMetricsW (dc, 0, NULL); + len = get_outline_metrics_w (dc, 0, NULL); if (len) { metrics = (OUTLINETEXTMETRICW *) alloca (len); - if (GetOutlineTextMetricsW (dc, len, metrics)) + if (get_outline_metrics_w (dc, len, metrics)) memcpy (&w32_font->metrics, &metrics->otmTextMetrics, sizeof (TEXTMETRICW)); else @@ -828,7 +959,7 @@ w32font_open_internal (FRAME_PTR f, Lisp_Object font_entity, } if (!metrics) - GetTextMetricsW (dc, &w32_font->metrics); + get_text_metrics_w (dc, &w32_font->metrics); w32_font->cached_metrics = NULL; w32_font->n_cache_blocks = 0; @@ -2306,7 +2437,7 @@ compute_metrics (HDC dc, struct w32font_info *w32_font, unsigned int code, transform.eM11.value = 1; transform.eM22.value = 1; - if (GetGlyphOutlineW (dc, code, options, &gm, 0, NULL, &transform) + if (get_glyph_outline_w (dc, code, options, &gm, 0, NULL, &transform) != GDI_ERROR) { metrics->lbearing = gm.gmptGlyphOrigin.x; @@ -2581,3 +2712,13 @@ versions of Windows) characters. */); w32font_driver.type = Qgdi; register_font_driver (&w32font_driver, NULL); } + +void +globals_of_w32font (void) +{ + g_b_init_is_w9x = 0; + g_b_init_get_outline_metrics_w = 0; + g_b_init_get_text_metrics_w = 0; + g_b_init_get_glyph_outline_w = 0; +} + From c20992f469ce64c052f95d7fcfa361b150bd379d Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Fri, 28 Oct 2011 12:59:24 +0200 Subject: [PATCH 09/18] src/w32font.c (w32_load_unicows_or_gdi32): Add missing return. --- src/ChangeLog | 4 ++++ src/w32font.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index a53c16e9da4..46cffde0806 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2011-10-28 Juanma Barranquero + + * w32font.c (w32_load_unicows_or_gdi32): Add missing return. + 2011-10-28 Eli Zaretskii Fix Emacs on Windows 9X (bug#8562). Thanks to oslsachem diff --git a/src/w32font.c b/src/w32font.c index fb41989caa7..6c1b4d0bc20 100644 --- a/src/w32font.c +++ b/src/w32font.c @@ -216,6 +216,7 @@ w32_load_unicows_or_gdi32 (void) } else ret = LoadLibrary ("Gdi32.dll"); + return ret; } /* The following 3 functions call the problematic "wide" APIs via @@ -2721,4 +2722,3 @@ globals_of_w32font (void) g_b_init_get_text_metrics_w = 0; g_b_init_get_glyph_outline_w = 0; } - From 9aba60432c25b060680eb7db698b20b05d7b94a0 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 28 Oct 2011 09:48:19 -0400 Subject: [PATCH 10/18] * src/lisp.h (struct Lisp_Symbol): Update comments. --- src/ChangeLog | 16 ++++--- src/keyboard.c | 124 ++++++++++++++++++++++++------------------------- src/lisp.h | 20 +++----- 3 files changed, 79 insertions(+), 81 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 46cffde0806..50fc953024a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2011-10-28 Stefan Monnier + + * lisp.h (struct Lisp_Symbol): Update comments. + 2011-10-28 Juanma Barranquero * w32font.c (w32_load_unicows_or_gdi32): Add missing return. @@ -13,10 +17,10 @@ (GetOutlineTextMetricsW_Proc, GetTextMetricsW_Proc) (GetGlyphOutlineW_Proc): New typedefs. (w32_load_unicows_or_gdi32, get_outline_metrics_w) - (get_text_metrics_w, get_glyph_outline_w, globals_of_w32font): New - functions. - (w32font_open_internal, compute_metrics): Call - get_outline_metrics_w, get_text_metrics_w, and get_glyph_outline_w + (get_text_metrics_w, get_glyph_outline_w, globals_of_w32font): + New functions. + (w32font_open_internal, compute_metrics): + Call get_outline_metrics_w, get_text_metrics_w, and get_glyph_outline_w instead of calling the "wide" APIs directly. * emacs.c (main) [HAVE_NTGUI]: Call globals_of_w32font. @@ -43,8 +47,8 @@ 2011-10-27 Chong Yidong - * gnutls.c (emacs_gnutls_deinit): New function. Deallocate - credentials structures as well as calling gnutls_deinit. + * gnutls.c (emacs_gnutls_deinit): New function. + Deallocate credentials structures as well as calling gnutls_deinit. (Fgnutls_deinit, Fgnutls_boot): Use it. * process.c (make_process): Initialize GnuTLS credentials to NULL. diff --git a/src/keyboard.c b/src/keyboard.c index eb316947dcb..95604550c80 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -73,7 +73,7 @@ along with GNU Emacs. If not, see . */ #include "nsterm.h" #endif -/* Variables for blockinput.h: */ +/* Variables for blockinput.h: */ /* Non-zero if interrupt input is blocked right now. */ volatile int interrupt_input_blocked; @@ -338,7 +338,7 @@ static Lisp_Object Qconfig_changed_event; Lisp_Object Qevent_kind; static Lisp_Object Qevent_symbol_elements; -/* menu and tool bar item parts */ +/* Menu and tool bar item parts. */ static Lisp_Object Qmenu_enable; static Lisp_Object QCenable, QCvisible, QChelp, QCkeys, QCkey_sequence; Lisp_Object QCfilter; @@ -835,7 +835,7 @@ recursive_edit_unwind (Lisp_Object buffer) #if 0 /* These two functions are now replaced with - temporarily_switch_to_single_kboard. */ + temporarily_switch_to_single_kboard. */ static void any_kboard_state () { @@ -1038,7 +1038,7 @@ cmd_error (Lisp_Object data) Vquit_flag = Qnil; Vinhibit_quit = Qnil; -#if 0 /* This shouldn't be necessary anymore. --lorentey */ +#if 0 /* This shouldn't be necessary anymore. --lorentey */ if (command_loop_level == 0 && minibuf_level == 0) any_kboard_state (); #endif @@ -1131,7 +1131,7 @@ command_loop (void) #if 0 /* This shouldn't be necessary anymore. --lorentey */ /* Reset single_kboard in case top-level set it while evaluating an -f option, or we are stuck there for some - other reason. */ + other reason. */ any_kboard_state (); #endif internal_catch (Qtop_level, command_loop_2, Qnil); @@ -1492,8 +1492,8 @@ command_loop_1 (void) if (!NILP (Vquit_flag)) { Vexecuting_kbd_macro = Qt; - QUIT; /* Make some noise. */ - /* Will return since macro now empty. */ + QUIT; /* Make some noise. */ + /* Will return since macro now empty. */ } } @@ -1512,7 +1512,7 @@ command_loop_1 (void) Vdisable_point_adjustment = Qnil; /* Process filters and timers may have messed with deactivate-mark. - reset it before we execute the command. */ + reset it before we execute the command. */ Vdeactivate_mark = Qnil; /* Remap command through active keymaps. */ @@ -1552,7 +1552,7 @@ command_loop_1 (void) } else { - /* Here for a command that isn't executed directly */ + /* Here for a command that isn't executed directly. */ #ifdef HAVE_WINDOW_SYSTEM int scount = SPECPDL_INDEX (); @@ -1960,7 +1960,7 @@ void poll_for_input_1 (void) { /* Tell ns_read_socket() it is being called asynchronously so it can avoid - doing anything dangerous. */ + doing anything dangerous. */ #ifdef HAVE_NS ++handling_signal; #endif @@ -2000,7 +2000,7 @@ start_polling (void) #ifdef POLL_FOR_INPUT /* XXX This condition was (read_socket_hook && !interrupt_input), but read_socket_hook is not global anymore. Let's pretend that - it's always set. */ + it's always set. */ if (!interrupt_input) { /* Turn alarm handling on unconditionally. It might have @@ -2037,7 +2037,7 @@ input_polling_used (void) #ifdef POLL_FOR_INPUT /* XXX This condition was (read_socket_hook && !interrupt_input), but read_socket_hook is not global anymore. Let's pretend that - it's always set. */ + it's always set. */ return !interrupt_input; #else return 0; @@ -2052,7 +2052,7 @@ stop_polling (void) #ifdef POLL_FOR_INPUT /* XXX This condition was (read_socket_hook && !interrupt_input), but read_socket_hook is not global anymore. Let's pretend that - it's always set. */ + it's always set. */ if (!interrupt_input) ++poll_suppress_count; #endif @@ -2390,7 +2390,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, real event came from. Normally, a switch-frame event selects internal_last_event_frame after each command is read, but events read from a macro should never cause a new frame to be - selected. */ + selected. */ Vlast_event_frame = internal_last_event_frame = Qmacro; /* Exit the macro if we are at the end. @@ -2500,7 +2500,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, Try this before the sit-for, because the sit-for would do the wrong thing if we are supposed to do menu prompting. If EVENT_HAS_PARAMETERS then we are reading - after a mouse event so don't try a minibuf menu. */ + after a mouse event so don't try a minibuf menu. */ c = Qnil; if (nmaps > 0 && INTERACTIVE && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event) @@ -4980,8 +4980,8 @@ static const char *const lispy_function_keys[] = "break", /* 0xff6b */ 0, 0, 0, 0, - 0, 0, 0, 0, "backtab", 0, 0, 0, /* 0xff70... */ - 0, 0, 0, 0, 0, 0, 0, "kp-numlock", /* 0xff78... */ + 0, 0, 0, 0, "backtab", 0, 0, 0, /* 0xff70... */ + 0, 0, 0, 0, 0, 0, 0, "kp-numlock", /* 0xff78... */ "kp-space", /* 0xff80 */ /* IsKeypadKey */ 0, 0, 0, 0, 0, 0, 0, 0, "kp-tab", /* 0xff89 */ @@ -5093,14 +5093,14 @@ static Lisp_Object *const scroll_bar_parts[] = { static Lisp_Object button_down_location; /* Information about the most recent up-going button event: Which - button, what location, and what time. */ + button, what location, and what time. */ static int last_mouse_button; static int last_mouse_x; static int last_mouse_y; static Time button_down_time; -/* The number of clicks in this multiple-click. */ +/* The number of clicks in this multiple-click. */ static int double_click_count; @@ -5344,7 +5344,7 @@ make_lispy_event (struct input_event *event) #ifdef HAVE_NS /* NS_NONKEY_EVENTs are just like NON_ASCII_KEYSTROKE_EVENTs, - except that they are non-key events (last-nonmenu-event is nil). */ + except that they are non-key events (last-nonmenu-event is nil). */ case NS_NONKEY_EVENT: #endif @@ -5830,7 +5830,7 @@ make_lispy_event (struct input_event *event) Fcons (make_number (event->timestamp), Fcons (part, Qnil))))); - /* Always treat scroll bar events as clicks. */ + /* Always treat scroll bar events as clicks. */ event->modifiers |= click_modifier; event->modifiers &= ~up_modifier; @@ -6694,7 +6694,7 @@ lucid_event_type_list_p (Lisp_Object object) If READABLE_EVENTS_FILTER_EVENTS is set in FLAGS, ignore internal events (FOCUS_IN_EVENT). If READABLE_EVENTS_IGNORE_SQUEEZABLES is set in FLAGS, ignore mouse - movements and toolkit scroll bar thumb drags. */ + movements and toolkit scroll bar thumb drags. */ static void get_input_pending (int *addr, int flags) @@ -6728,7 +6728,7 @@ gobble_input (int expected) #ifdef POLL_FOR_INPUT /* XXX This condition was (read_socket_hook && !interrupt_input), but read_socket_hook is not global anymore. Let's pretend that - it's always set. */ + it's always set. */ if (!interrupt_input && poll_suppress_count == 0) { SIGMASKTYPE mask; @@ -6803,7 +6803,7 @@ read_avail_input (int expected) if (store_user_signal_events ()) expected = 0; - /* Loop through the available terminals, and call their input hooks. */ + /* Loop through the available terminals, and call their input hooks. */ t = terminal_list; while (t) { @@ -6824,15 +6824,15 @@ read_avail_input (int expected) expected = 0; } - if (nr == -1) /* Not OK to read input now. */ + if (nr == -1) /* Not OK to read input now. */ { err = 1; } - else if (nr == -2) /* Non-transient error. */ + else if (nr == -2) /* Non-transient error. */ { - /* The terminal device terminated; it should be closed. */ + /* The terminal device terminated; it should be closed. */ - /* Kill Emacs if this was our last terminal. */ + /* Kill Emacs if this was our last terminal. */ if (!terminal_list->next_terminal) /* Formerly simply reported no input, but that sometimes led to a failure of Emacs to terminate. @@ -6844,7 +6844,7 @@ read_avail_input (int expected) alone in its group. */ kill (getpid (), SIGHUP); - /* XXX Is calling delete_terminal safe here? It calls delete_frame. */ + /* XXX Is calling delete_terminal safe here? It calls delete_frame. */ { Lisp_Object tmp; XSETTERMINAL (tmp, t); @@ -6934,7 +6934,7 @@ tty_read_avail_input (struct terminal *terminal, return 0; #endif /* subprocesses */ - if (!terminal->name) /* Don't read from a dead terminal. */ + if (!terminal->name) /* Don't read from a dead terminal. */ return 0; if (terminal->type != output_termcap @@ -6942,15 +6942,15 @@ tty_read_avail_input (struct terminal *terminal, abort (); /* XXX I think the following code should be moved to separate hook - functions in system-dependent files. */ + functions in system-dependent files. */ #ifdef WINDOWSNT return 0; #else /* not WINDOWSNT */ - if (! tty->term_initted) /* In case we get called during bootstrap. */ + if (! tty->term_initted) /* In case we get called during bootstrap. */ return 0; if (! tty->input) - return 0; /* The terminal is suspended. */ + return 0; /* The terminal is suspended. */ #ifdef MSDOS n_to_read = dos_keysns (); @@ -6976,7 +6976,7 @@ tty_read_avail_input (struct terminal *terminal, Gpm_GetEvent closes gpm_fd and clears it to -1, which is why we save it in `fd' so close_gpm can remove it from the select masks. - gpm==-1 if a protocol error or EWOULDBLOCK; the latter is normal. */ + gpm==-1 if a protocol error or EWOULDBLOCK; the latter is normal. */ while (gpm = Gpm_GetEvent (&event), gpm == 1) { nread += handle_one_term_event (tty, &event, &gpm_hold_quit); } @@ -6996,7 +6996,7 @@ tty_read_avail_input (struct terminal *terminal, if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0) { if (! noninteractive) - return -2; /* Close this terminal. */ + return -2; /* Close this terminal. */ else n_to_read = 0; } @@ -7029,16 +7029,16 @@ tty_read_avail_input (struct terminal *terminal, process group won't get SIGHUP's at logout time. BSDI adheres to this part standard and returns -1 from read (0) with errno==EIO when the control tty is taken away. - Jeffrey Honig says this is generally safe. */ + Jeffrey Honig says this is generally safe. */ if (nread == -1 && errno == EIO) - return -2; /* Close this terminal. */ + return -2; /* Close this terminal. */ #if defined (AIX) && defined (_BSD) /* The kernel sometimes fails to deliver SIGHUP for ptys. This looks incorrect, but it isn't, because _BSD causes O_NDELAY to be defined in fcntl.h as O_NONBLOCK, and that causes a value other than 0 when there is no input. */ if (nread == 0) - return -2; /* Close this terminal. */ + return -2; /* Close this terminal. */ #endif } while ( @@ -7116,7 +7116,7 @@ tty_read_avail_input (struct terminal *terminal, buf.code = cbuf[i]; /* Set the frame corresponding to the active tty. Note that the value of selected_frame is not reliable here, redisplay tends - to temporarily change it. */ + to temporarily change it. */ buf.frame_or_window = tty->top_frame; buf.arg = Qnil; @@ -7139,7 +7139,7 @@ handle_async_input (void) pending_signals = pending_atimers; #endif /* Tell ns_read_socket() it is being called asynchronously so it can avoid - doing anything dangerous. */ + doing anything dangerous. */ #ifdef HAVE_NS ++handling_signal; #endif @@ -7197,7 +7197,7 @@ input_available_signal (int signo) This function exists so that the UNBLOCK_INPUT macro in blockinput.h can have some way to take care of input we put off dealing with, without assuming that every file which uses - UNBLOCK_INPUT also has #included the files necessary to get SIGIO. */ + UNBLOCK_INPUT also has #included the files necessary to get SIGIO. */ void reinvoke_input_signal (void) { @@ -7224,7 +7224,7 @@ struct user_signal_info struct user_signal_info *next; }; -/* List of user signals. */ +/* List of user signals. */ static struct user_signal_info *user_signals = NULL; void @@ -7761,7 +7761,7 @@ parse_menu_item (Lisp_Object item, int inmenubar) { tem = XCAR (item); if (SYMBOLP (tem) || STRINGP (tem) || VECTORP (tem)) - /* Be GC protected. Set keyhint to item instead of tem. */ + /* Be GC protected. Set keyhint to item instead of tem. */ keyhint = item; } else if (EQ (tem, QCkeys)) @@ -7844,7 +7844,7 @@ parse_menu_item (Lisp_Object item, int inmenubar) if (inmenubar > 0) return 1; - { /* This is a command. See if there is an equivalent key binding. */ + { /* This is a command. See if there is an equivalent key binding. */ Lisp_Object keyeq = AREF (item_properties, ITEM_PROPERTY_KEYEQ); /* The previous code preferred :key-sequence to :keys, so we @@ -8400,7 +8400,7 @@ append_tool_bar_item (void) These are done in different ways, depending on how the input will be read. Menus using X are done after auto-saving in read-char, getting the input event from Fx_popup_menu; menus using the minibuf use read_char recursively - and do auto-saving in the inner call of read_char. */ + and do auto-saving in the inner call of read_char. */ static Lisp_Object read_char_x_menu_prompt (ptrdiff_t nmaps, Lisp_Object *maps, @@ -8620,14 +8620,14 @@ read_char_minibuf_menu_prompt (int commandflag, tem = XVECTOR (item_properties)->contents[ITEM_PROPERTY_KEYEQ]; if (!NILP (tem)) - /* Insert equivalent keybinding. */ + /* Insert equivalent keybinding. */ s = concat2 (s, tem); #endif tem = XVECTOR (item_properties)->contents[ITEM_PROPERTY_TYPE]; if (EQ (tem, QCradio) || EQ (tem, QCtoggle)) { - /* Insert button prefix. */ + /* Insert button prefix. */ Lisp_Object selected = XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED]; if (EQ (tem, QCradio)) @@ -8861,7 +8861,7 @@ keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey, /* If keybuf[fkey->start..fkey->end] is bound in the map and we're in a position to do the key remapping, replace it with - the binding and restart with fkey->start at the end. */ + the binding and restart with fkey->start at the end. */ if ((VECTORP (next) || STRINGP (next)) && doit) { int len = XFASTINT (Flength (next)); @@ -9025,7 +9025,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, /* Non-zero if we are trying to map a key by changing an upper-case letter to lower case, or a shifted function key to an unshifted - one. */ + one. */ int shift_translated = 0; /* If we receive a `switch-frame' or `select-window' event in the middle of @@ -9033,7 +9033,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, While we're reading, we keep the event here. */ Lisp_Object delayed_switch_frame; - /* See the comment below... */ + /* See the comment below... */ #if defined (GOBBLE_FIRST_EVENT) Lisp_Object first_event; #endif @@ -9308,7 +9308,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, if (!found) { /* Don't touch interrupted_kboard when it's been - deleted. */ + deleted. */ delayed_switch_frame = Qnil; goto replay_entire_sequence; } @@ -9416,7 +9416,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, { /* If we're at the beginning of a key sequence, and the caller says it's okay, go ahead and return this event. If we're - in the midst of a key sequence, delay it until the end. */ + in the midst of a key sequence, delay it until the end. */ if (t > 0 || !can_return_switch_frame) { delayed_switch_frame = key; @@ -9713,7 +9713,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, Down-clicks are eliminated. Double-downs reduce to downs, then are eliminated. Triple-downs reduce to double-downs, then to downs, - then are eliminated. */ + then are eliminated. */ if (modifiers & (down_modifier | drag_modifier | double_modifier | triple_modifier)) { @@ -10822,7 +10822,7 @@ set_waiting_for_input (struct timeval *time_to_clear) waiting_for_input = 1; /* If handle_interrupt was called before and buffered a C-g, - make it run again now, to avoid timing error. */ + make it run again now, to avoid timing error. */ if (!NILP (Vquit_flag)) quit_throw_to_read_char (); } @@ -10843,7 +10843,7 @@ clear_waiting_for_input (void) static void interrupt_signal (int signalnum) /* If we don't have an argument, some */ - /* compilers complain in signal calls. */ + /* compilers complain in signal calls. */ { /* Must preserve main program's value of errno. */ int old_errno = errno; @@ -10851,12 +10851,12 @@ interrupt_signal (int signalnum) /* If we don't have an argument, some */ SIGNAL_THREAD_CHECK (signalnum); - /* See if we have an active terminal on our controlling tty. */ + /* See if we have an active terminal on our controlling tty. */ terminal = get_named_tty ("/dev/tty"); if (!terminal) { /* If there are no frames there, let's pretend that we are a - well-behaving UN*X program and quit. */ + well-behaving UN*X program and quit. */ Fkill_emacs (Qnil); } else @@ -10884,7 +10884,7 @@ interrupt_signal (int signalnum) /* If we don't have an argument, some */ Otherwise it sets the Lisp variable quit-flag not-nil. This causes eval to throw, when it gets a chance. If quit-flag is already - non-nil, it stops the job right away. */ + non-nil, it stops the job right away. */ static void handle_interrupt (void) @@ -10893,7 +10893,7 @@ handle_interrupt (void) cancel_echoing (); - /* XXX This code needs to be revised for multi-tty support. */ + /* XXX This code needs to be revised for multi-tty support. */ if (!NILP (Vquit_flag) && get_named_tty ("/dev/tty")) { /* If SIGINT isn't blocked, don't let us be interrupted by @@ -11003,7 +11003,7 @@ handle_interrupt (void) wait_reading_process_output() under HAVE_NS because of the call to ns_select there (needed because otherwise events aren't picked up outside of polling since we don't get SIGIO like X and we don't have a - separate event loop thread like W32. */ + separate event loop thread like W32. */ #ifndef HAVE_NS if (waiting_for_input && !echoing) quit_throw_to_read_char (); @@ -11452,7 +11452,7 @@ init_keyboard (void) session may have multiple display types, so we always handle SIGINT. There is special code in interrupt_signal to exit Emacs on SIGINT when there are no termcap frames on the - controlling terminal. */ + controlling terminal. */ signal (SIGINT, interrupt_signal); #ifndef DOS_NT /* For systems with SysV TERMIO, C-g is set up for both SIGINT and @@ -12249,7 +12249,7 @@ Currently, the only supported values for this variable are `sigusr1' and `sigusr2'. */); Vdebug_on_event = intern_c_string ("sigusr2"); - /* Create the initial keyboard. */ + /* Create the initial keyboard. */ initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); init_kboard (initial_kboard); /* Vwindow_system is left at t for now. */ diff --git a/src/lisp.h b/src/lisp.h index 1bbb5633fe5..df8812f73b7 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -162,7 +162,7 @@ extern int suppress_checking EXTERNALLY_VISIBLE; /* First, try and define DECL_ALIGN(type,var) which declares a static variable VAR of type TYPE with the added requirement that it be - TYPEBITS-aligned. */ + TYPEBITS-aligned. */ #ifndef NO_DECL_ALIGN # ifndef DECL_ALIGN # if HAVE_ATTRIBUTE_ALIGNED @@ -1084,11 +1084,9 @@ enum symbol_redirect SYMBOL_PLAINVAL = 4, SYMBOL_VARALIAS = 1, SYMBOL_LOCALIZED = 2, - SYMBOL_FORWARDED = 3 + SYMBOL_FORWARDED = 3 }; -/* In a symbol, the markbit of the plist is used as the gc mark bit */ - struct Lisp_Symbol { unsigned gcmarkbit : 1; @@ -1097,8 +1095,7 @@ struct Lisp_Symbol 0 : it's a plain var, the value is in the `value' field. 1 : it's a varalias, the value is really in the `alias' symbol. 2 : it's a localized var, the value is in the `blv' object. - 3 : it's a forwarding variable, the value is in `forward'. - */ + 3 : it's a forwarding variable, the value is in `forward'. */ enum symbol_redirect redirect : 3; /* Non-zero means symbol is constant, i.e. changing its value @@ -1115,15 +1112,12 @@ struct Lisp_Symbol unsigned declared_special : 1; /* The symbol's name, as a Lisp string. - The name "xname" is used to intentionally break code referring to the old field "name" of type pointer to struct Lisp_String. */ Lisp_Object xname; - /* Value of the symbol or Qunbound if unbound. If this symbol is a - defvaralias, `alias' contains the symbol for which it is an - alias. Use the SYMBOL_VALUE and SET_SYMBOL_VALUE macros to get - and set a symbol's value, to take defvaralias into account. */ + /* Value of the symbol or Qunbound if unbound. Which alternative of the + union is used depends on the `redirect' field above. */ union { Lisp_Object value; struct Lisp_Symbol *alias; @@ -1318,7 +1312,7 @@ struct Lisp_Misc_Any /* Supertype of all Misc types. */ enum Lisp_Misc_Type type : 16; /* = Lisp_Misc_??? */ unsigned gcmarkbit : 1; int spacer : 15; - /* Make it as long as "Lisp_Free without padding". */ + /* Make it as long as "Lisp_Free without padding". */ void *fill; }; @@ -3603,7 +3597,7 @@ extern void init_system_name (void); #define SWITCH_ENUM_CAST(x) (x) -/* Use this to suppress gcc's warnings. */ +/* Use this to suppress gcc's warnings. */ #ifdef lint /* Use CODE only if lint checking is in effect. */ From 31b39d1389640fa5677c8f86a2944a1197f4ada8 Mon Sep 17 00:00:00 2001 From: Dan Nicolaescu Date: Fri, 28 Oct 2011 08:34:06 -0600 Subject: [PATCH 11/18] * src/window.c (make_window): Initialize phys_cursor_on_p. --- src/ChangeLog | 4 ++++ src/window.c | 1 + 2 files changed, 5 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index 50fc953024a..21ec98fa217 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2011-10-28 Dan Nicolaescu + + * window.c (make_window): Initialize phys_cursor_on_p. + 2011-10-28 Stefan Monnier * lisp.h (struct Lisp_Symbol): Update comments. diff --git a/src/window.c b/src/window.c index 0c35b913789..38f16c91f34 100644 --- a/src/window.c +++ b/src/window.c @@ -3320,6 +3320,7 @@ make_window (void) memset (&w->phys_cursor, 0, sizeof (w->phys_cursor)); w->phys_cursor_type = -1; w->phys_cursor_width = -1; + w->phys_cursor_on_p = 0; w->last_cursor_off_p = w->cursor_off_p = 0; w->must_be_updated_p = 0; w->pseudo_window_p = 0; From 020716e178cdae443a3630c4307023cb3fc4c350 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Fri, 28 Oct 2011 14:34:39 +0000 Subject: [PATCH 12/18] DTRT for c-beginning/end-of-defun in nested declaration scopes. --- doc/misc/cc-mode.texi | 11 ++ lisp/progmodes/cc-cmds.el | 272 +++++++++++++++++++++++++----------- lisp/progmodes/cc-engine.el | 32 ++++- lisp/progmodes/cc-vars.el | 14 ++ 4 files changed, 246 insertions(+), 83 deletions(-) diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi index a9339162666..8818904982b 100644 --- a/doc/misc/cc-mode.texi +++ b/doc/misc/cc-mode.texi @@ -882,6 +882,8 @@ lines. @itemx @kbd{C-M-e} (@code{c-end-of-defun}) @findex c-beginning-of-defun @findex c-end-of-defun +@vindex c-defun-tactic +@vindex defun-tactic (c-) Move to the beginning or end of the current or next function. Other constructs (such as a structs or classes) which have a brace block @@ -895,6 +897,15 @@ commands try to leave point at the beginning of a line near the actual start or end of the function. This occasionally causes point not to move at all. +By default, these commands will recognize functions contained within a +@dfn{declaration scope} such as a C++ @code{class} or @code{namespace} +construct, should the point start inside it. If @ccmode fails to find +function beginnings or ends inside the current declaration scope, it +will search the enclosing scopes. If you want @ccmode to recognize +functions only at the top level@footnote{this was @ccmode{}'s +behaviour prior to version 5.32.}, set @code{c-defun-tatic} to +@code{t}. + These functions are analogous to the Emacs built-in commands @code{beginning-of-defun} and @code{end-of-defun}, except they eliminate the constraint that the top-level opening brace of the defun diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 0f873e678c3..e59fdc16af7 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -1485,6 +1485,78 @@ No indentation or other \"electric\" behavior is performed." (setq n (1- n)))) n) +(defun c-narrow-to-most-enclosing-decl-block (&optional inclusive) + ;; If we are inside a decl-block (in the sense of c-looking-at-decl-block), + ;; i.e. something like namespace{} or extern{}, narrow to the insides of + ;; that block (NOT including the enclosing braces) if INCLUSIVE is nil, + ;; otherwise include the braces. If the closing brace is missing, + ;; (point-max) is used instead. + (let ((paren-state (c-parse-state)) + encl-decl) + (setq encl-decl (and paren-state (c-most-enclosing-decl-block paren-state))) + (if encl-decl + (save-excursion + (narrow-to-region + (if inclusive + (progn (goto-char encl-decl) + (c-beginning-of-decl-1) + (point)) + (1+ encl-decl)) + (progn + (goto-char encl-decl) + (or (c-safe (forward-list) + (if inclusive + (point) + (1- (point)))) + (point-max)))))))) + +(defun c-widen-to-enclosing-decl-scope (paren-state orig-point-min orig-point-max) + ;; Narrow the buffer to the innermost declaration scope (e.g. a class, a + ;; namespace or the "whole buffer") recorded in PAREN-STATE, the bounding + ;; braces NOT being included in the resulting region. On no account may the + ;; final region exceed that bounded by ORIG-POINT-MIN, ORIG-POINT-MAX. + ;; PAREN-STATE is a list of buffer positions in the style of + ;; (c-parse-state), one of which will be that of the desired opening brace, + ;; if there is one. + ;; + ;; Return the position of the enclosing opening brace, or nil + (let (encl-decl) ; putative position of decl-scope's opening brace. + (save-restriction + (narrow-to-region orig-point-min orig-point-max) + (setq encl-decl (and paren-state + (c-most-enclosing-decl-block paren-state)))) + (if encl-decl + (progn + (widen) + (narrow-to-region (1+ encl-decl) + (save-excursion + (goto-char encl-decl) + (or (c-safe (forward-list) + (1- (point))) + orig-point-max))) + encl-decl) + (narrow-to-region orig-point-min orig-point-max) + nil))) + +(eval-and-compile + (defmacro c-while-widening-to-decl-block (condition) + ;; Repeatedly evaluate CONDITION until it returns nil. After each + ;; evaluation, if `c-defun-tactic' is set appropriately, widen to innards + ;; of the next enclosing declaration block (e.g. namespace, class), or the + ;; buffer's original restriction. + ;; + ;; This is a very special purpose macro, which assumes the existence of + ;; several variables. It is for use only in c-beginning-of-defun and + ;; c-end-of-defun. + `(while + (and ,condition + (eq c-defun-tactic 'go-outward) + lim) + (setq paren-state (c-whack-state-after lim paren-state)) + (setq lim (c-widen-to-enclosing-decl-scope + paren-state orig-point-min orig-point-max)) + (setq where 'in-block)))) + (defun c-beginning-of-defun (&optional arg) "Move backward to the beginning of a defun. Every top level declaration that contains a brace paren block is @@ -1509,50 +1581,66 @@ defun." (c-save-buffer-state (beginning-of-defun-function end-of-defun-function (start (point)) - where paren-state pos) + (paren-state (copy-tree (c-parse-state))) ; This must not share list + ; structure with other users of c-state-cache. + (orig-point-min (point-min)) (orig-point-max (point-max)) + lim ; Position of { which has been widened to. + where pos) - ;; Move back out of any macro/comment/string we happen to be in. - (c-beginning-of-macro) - (setq pos (c-literal-limits)) - (if pos (goto-char (car pos))) + (save-restriction + (if (eq c-defun-tactic 'go-outward) + (setq lim (c-widen-to-enclosing-decl-scope ; e.g. class, namespace. + paren-state orig-point-min orig-point-max))) - (setq where (c-where-wrt-brace-construct)) + ;; Move back out of any macro/comment/string we happen to be in. + (c-beginning-of-macro) + (setq pos (c-literal-limits)) + (if pos (goto-char (car pos))) - (if (< arg 0) - ;; Move forward to the closing brace of a function. - (progn - (if (memq where '(at-function-end outwith-function)) - (setq arg (1+ arg))) - (if (< arg 0) - (setq arg (c-forward-to-nth-EOF-} (- arg) where))) - ;; Move forward to the next opening brace.... - (when (and (= arg 0) - (c-syntactic-re-search-forward "{" nil 'eob)) - (backward-char) - ;; ... and backward to the function header. - (c-beginning-of-decl-1) - t)) + (setq where (c-where-wrt-brace-construct)) - ;; Move backward to the opening brace of a function. - (when (and (> arg 0) - (eq (setq arg (c-backward-to-nth-BOF-{ arg where)) 0)) + (if (< arg 0) + ;; Move forward to the closing brace of a function. + (progn + (if (memq where '(at-function-end outwith-function)) + (setq arg (1+ arg))) + (if (< arg 0) + (c-while-widening-to-decl-block + (< (setq arg (- (c-forward-to-nth-EOF-} (- arg) where))) 0))) + ;; Move forward to the next opening brace.... + (when (and (= arg 0) + (progn + (c-while-widening-to-decl-block + (not (c-syntactic-re-search-forward "{" nil 'eob))) + (eq (char-before) ?{))) + (backward-char) + ;; ... and backward to the function header. + (c-beginning-of-decl-1) + t)) - ;; Go backward to this function's header. - (c-beginning-of-decl-1) + ;; Move backward to the opening brace of a function, making successively + ;; larger portions of the buffer visible as necessary. + (when (> arg 0) + (c-while-widening-to-decl-block + (> (setq arg (c-backward-to-nth-BOF-{ arg where)) 0))) - (setq pos (point)) - ;; We're now there, modulo comments and whitespace. - ;; Try to be line oriented; position point at the closest - ;; preceding boi that isn't inside a comment, but if we hit - ;; the previous declaration then we use the current point - ;; instead. - (while (and (/= (point) (c-point 'boi)) - (c-backward-single-comment))) - (if (/= (point) (c-point 'boi)) - (goto-char pos))) + (when (eq arg 0) + ;; Go backward to this function's header. + (c-beginning-of-decl-1) - (c-keep-region-active) - (= arg 0)))) + (setq pos (point)) + ;; We're now there, modulo comments and whitespace. + ;; Try to be line oriented; position point at the closest + ;; preceding boi that isn't inside a comment, but if we hit + ;; the previous declaration then we use the current point + ;; instead. + (while (and (/= (point) (c-point 'boi)) + (c-backward-single-comment))) + (if (/= (point) (c-point 'boi)) + (goto-char pos))) + + (c-keep-region-active) + (= arg 0))))) (defun c-forward-to-nth-EOF-} (n where) ;; Skip to the closing brace of the Nth function after point. If @@ -1617,50 +1705,62 @@ the open-parenthesis that starts a defun; see `beginning-of-defun'." (c-save-buffer-state (beginning-of-defun-function end-of-defun-function (start (point)) - where paren-state pos) + (paren-state (copy-tree (c-parse-state))) ; This must not share list + ; structure with other users of c-state-cache. + (orig-point-min (point-min)) (orig-point-max (point-max)) + lim + where pos) + (save-restriction + (if (eq c-defun-tactic 'go-outward) + (setq lim (c-widen-to-enclosing-decl-scope ; e.g. class, namespace + paren-state orig-point-min orig-point-max))) - ;; Move back out of any macro/comment/string we happen to be in. - (c-beginning-of-macro) - (setq pos (c-literal-limits)) - (if pos (goto-char (car pos))) + ;; Move back out of any macro/comment/string we happen to be in. + (c-beginning-of-macro) + (setq pos (c-literal-limits)) + (if pos (goto-char (car pos))) - (setq where (c-where-wrt-brace-construct)) + (setq where (c-where-wrt-brace-construct)) - (if (< arg 0) - ;; Move backwards to the } of a function - (progn - (if (memq where '(at-header outwith-function)) - (setq arg (1+ arg))) - (if (< arg 0) - (setq arg (c-backward-to-nth-BOF-{ (- arg) where))) - (if (= arg 0) - (c-syntactic-skip-backward "^}"))) + (if (< arg 0) + ;; Move backwards to the } of a function + (progn + (if (memq where '(at-header outwith-function)) + (setq arg (1+ arg))) + (if (< arg 0) + (c-while-widening-to-decl-block + (< (setq arg (- (c-backward-to-nth-BOF-{ (- arg) where))) 0))) + (if (= arg 0) + (c-while-widening-to-decl-block + (progn (c-syntactic-skip-backward "^}") + (not (eq (char-before) ?})))))) - ;; Move forward to the } of a function - (if (> arg 0) - (setq arg (c-forward-to-nth-EOF-} arg where)))) + ;; Move forward to the } of a function + (if (> arg 0) + (c-while-widening-to-decl-block + (> (setq arg (c-forward-to-nth-EOF-} arg where)) 0)))) - ;; Do we need to move forward from the brace to the semicolon? - (when (eq arg 0) - (if (c-in-function-trailer-p) ; after "}" of struct/enum, etc. - (c-syntactic-re-search-forward ";")) + ;; Do we need to move forward from the brace to the semicolon? + (when (eq arg 0) + (if (c-in-function-trailer-p) ; after "}" of struct/enum, etc. + (c-syntactic-re-search-forward ";")) - (setq pos (point)) - ;; We're there now, modulo comments and whitespace. - ;; Try to be line oriented; position point after the next - ;; newline that isn't inside a comment, but if we hit the - ;; next declaration then we use the current point instead. - (while (and (not (bolp)) - (not (looking-at "\\s *$")) - (c-forward-single-comment))) - (cond ((bolp)) - ((looking-at "\\s *$") - (forward-line 1)) - (t - (goto-char pos)))) + (setq pos (point)) + ;; We're there now, modulo comments and whitespace. + ;; Try to be line oriented; position point after the next + ;; newline that isn't inside a comment, but if we hit the + ;; next declaration then we use the current point instead. + (while (and (not (bolp)) + (not (looking-at "\\s *$")) + (c-forward-single-comment))) + (cond ((bolp)) + ((looking-at "\\s *$") + (forward-line 1)) + (t + (goto-char pos)))) - (c-keep-region-active) - (= arg 0))) + (c-keep-region-active) + (= arg 0)))) (defun c-defun-name () "Return the name of the current defun, or NIL if there isn't one. @@ -1746,6 +1846,11 @@ with a brace block." ;; ;; This function might do hidden buffer changes. (save-excursion + (save-restriction + (when (eq c-defun-tactic 'go-outward) + (c-narrow-to-most-enclosing-decl-block t) ; e.g. class, namespace + (or (save-restriction + (c-narrow-to-most-enclosing-decl-block nil) ;; Note: Some code duplication in `c-beginning-of-defun' and ;; `c-end-of-defun'. @@ -1755,11 +1860,12 @@ with a brace block." lim pos end-pos) (unless (c-safe (goto-char (c-least-enclosing-brace paren-state)) - ;; If we moved to the outermost enclosing paren then we - ;; can use c-safe-position to set the limit. Can't do - ;; that otherwise since the earlier paren pair on - ;; paren-state might very well be part of the - ;; declaration we should go to. + ;; If we moved to the outermost enclosing paren + ;; then we can use c-safe-position to set the + ;; limit. Can't do that otherwise since the + ;; earlier paren pair on paren-state might very + ;; well be part of the declaration we should go + ;; to. (setq lim (c-safe-position (point) paren-state)) t) ;; At top level. Make sure we aren't inside a literal. @@ -1843,8 +1949,12 @@ with a brace block." (forward-line 1) (point)) (t - pos))))) - )))) + pos)))))))) + (and (not near) + (goto-char (point-min)) + (c-forward-decl-or-cast-1 -1 nil nil) + (eq (char-after) ?\{) + (cons (point-min) (point-max)))))))) (defun c-mark-function () "Put mark at end of the current top-level declaration or macro, point at beginning. diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index b2c548847c3..bc42e1032ab 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -705,7 +705,7 @@ comment at the start of cc-engine.el for more info." ;; The last position where a label is possible provided the ;; statement started there. It's nil as long as no invalid ;; label content has been found (according to - ;; `c-nonlabel-token-key'. It's `start' if no valid label + ;; `c-nonlabel-token-key'). It's `start' if no valid label ;; content was found in the label. Note that we might still ;; regard it a label if it starts with `c-label-kwds'. label-good-pos @@ -1035,7 +1035,12 @@ comment at the start of cc-engine.el for more info." ;; (including a case label) or something like C++'s "public:"? ;; A case label might use an expression rather than a token. (setq after-case:-pos (or tok start)) - (if (looking-at c-nonlabel-token-key) ; e.g. "while" or "'a'" + (if (or (looking-at c-nonlabel-token-key) ; e.g. "while" or "'a'" + ;; Catch C++'s inheritance construct "class foo : bar". + (save-excursion + (and + (c-safe (c-backward-sexp) t) + (looking-at c-nonlabel-token-2-key)))) (setq c-maybe-labelp nil) (if after-labels-pos ; Have we already encountered a label? (if (not last-label-pos) @@ -8037,6 +8042,29 @@ comment at the start of cc-engine.el for more info." (back-to-indentation) (vector (point) open-paren-pos)))))) +(defmacro c-pull-open-brace (ps) + ;; Pull the next open brace from PS (which has the form of paren-state), + ;; skipping over any brace pairs. Returns NIL when PS is exhausted. + `(progn + (while (consp (car ,ps)) + (setq ,ps (cdr ,ps))) + (prog1 (car ,ps) + (setq ,ps (cdr ,ps))))) + +(defun c-most-enclosing-decl-block (paren-state) + ;; Return the buffer position of the most enclosing decl-block brace (in the + ;; sense of c-looking-at-decl-block) in the PAREN-STATE structure, or nil if + ;; none was found. + (let* ((open-brace (c-pull-open-brace paren-state)) + (next-open-brace (c-pull-open-brace paren-state))) + (while (and open-brace + (save-excursion + (goto-char open-brace) + (not (c-looking-at-decl-block next-open-brace nil)))) + (setq open-brace next-open-brace + next-open-brace (c-pull-open-brace paren-state))) + open-brace)) + (defun c-inside-bracelist-p (containing-sexp paren-state) ;; return the buffer position of the beginning of the brace list ;; statement if we're inside a brace list, otherwise return nil. diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el index 58dc1737c5a..769bf63f63c 100644 --- a/lisp/progmodes/cc-vars.el +++ b/lisp/progmodes/cc-vars.el @@ -340,6 +340,20 @@ better with the \"do { ... } while \(0)\" trick)." :group 'c) (put 'c-syntactic-indentation-in-macros 'safe-local-variable 'booleanp) +(defcustom c-defun-tactic 'go-outward + "*Whether functions are recognized inside, e.g., a class. +This is used by `c-beginning-of-defun' and like functions. + +Its value is one of: + t -- Functions are recognized only at the top level. + go-outward -- Nested functions are also recognized. Should a function + command hit the beginning/end of a nested scope, it will + carry on at the less nested level." + :type '(radio + (const :tag "Functions are at the top-level" t) + (const :tag "Functions are also recognized inside declaration scopes" go-outward)) + :group 'c) + (defcustom-c-stylevar c-comment-only-line-offset 0 "*Extra offset for line which contains only the start of a comment. Can contain an integer or a cons cell of the form: From 1a2ce9ee38c720f26189cc5e17d56309e6dbb76b Mon Sep 17 00:00:00 2001 From: Deniz Dogan Date: Fri, 28 Oct 2011 16:47:50 +0200 Subject: [PATCH 13/18] * net/rcirc.el (rcirc-mode): Use hard newlines. --- lisp/ChangeLog | 4 ++++ lisp/net/rcirc.el | 1 + 2 files changed, 5 insertions(+) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bf4d87d3405..4ac4419b163 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2011-10-28 Deniz Dogan + + * net/rcirc.el (rcirc-mode): Use hard newlines. + 2011-10-28 Alan Mackenzie Amend to indent and fontify macros "which include their own semicolon" diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 6a912cd6273..f6981aeabd9 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -979,6 +979,7 @@ This number is independent of the number of lines in the buffer.") (set (make-local-variable 'rcirc-recent-quit-alist) nil) (set (make-local-variable 'rcirc-current-line) 0) + (use-hard-newlines t) (set (make-local-variable 'rcirc-short-buffer-name) nil) (set (make-local-variable 'rcirc-urls) nil) From 8cedc5acf983ed7736e8ad59528dbbf62bde7ade Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 28 Oct 2011 17:03:13 +0200 Subject: [PATCH 14/18] Document that UNICOWS.DLL is required to run Emacs on Windows 9X. nt/README.W32: Mention UNICOWS.DLL as prerequisite for running Emacs on Windows 9X. admin/nt/README-ftp-server: Mention UNICOWS.DLL as prerequisite for running Emacs on Windows 9X. Fixes: debbugs:8562 --- admin/ChangeLog | 5 +++++ admin/nt/README-ftp-server | 34 ++++++++++++++++++++-------------- nt/ChangeLog | 5 +++++ nt/README.W32 | 21 +++++++++++++++++++-- 4 files changed, 49 insertions(+), 16 deletions(-) diff --git a/admin/ChangeLog b/admin/ChangeLog index 7648b2a8455..7c2f1a743b2 100644 --- a/admin/ChangeLog +++ b/admin/ChangeLog @@ -1,3 +1,8 @@ +2011-10-28 Eli Zaretskii + + * nt/README-ftp-server: Mention UNICOWS.DLL as prerequisite for + running Emacs on Windows 9X. + 2011-09-26 Chong Yidong * admin.el (set-version): Fix regexps for config.nt and diff --git a/admin/nt/README-ftp-server b/admin/nt/README-ftp-server index 4310ac13dd5..5dee94f28c5 100644 --- a/admin/nt/README-ftp-server +++ b/admin/nt/README-ftp-server @@ -4,9 +4,9 @@ See the end of the file for license conditions. Precompiled Distributions of Emacs for Windows - Version 23.1 + Version 24.1 - July 29, 2009 + January 1, 2011 This directory contains precompiled distributions for GNU Emacs on Windows (versions before Windows 95 and NT4 are not supported). @@ -14,7 +14,7 @@ See the end of the file for license conditions. Free Software Foundation; the precompiled distributions are provided here for convenience since the majority of Windows users are not accustomed to compiling programs themselves. Corresponding source - can be found in the parent directory in emacs-23.1.tar.gz. + can be found in the parent directory in emacs-24.1.tar.gz. If you have access to the World Wide Web, I would recommend pointing your favorite web browser to the following document (if you haven't @@ -26,9 +26,9 @@ See the end of the file for license conditions. If you want to redistribute any of the precompiled distributions of Emacs, be careful to check the implications of the GPL. For instance, - if you put the emacs-23.1-bin-i386.tar.gz file from this directory on + if you put the emacs-24.1-bin-i386.tar.gz file from this directory on an Internet site, you must arrange to distribute the source files of - the SAME version (i.e. ../emacs-23.1.tar.gz). + the SAME version (i.e. ../emacs-24.1.tar.gz). Making a link to our copy of the source is NOT sufficient, since we might upgrade to a new version while you are still distributing the @@ -37,8 +37,8 @@ See the end of the file for license conditions. * Files in this directory - + emacs-23.1-bin-i386.zip - Windows binaries of Emacs-23.1, with all lisp code and documentation + + emacs-24.1-bin-i386.zip + Windows binaries of Emacs-24.1, with all lisp code and documentation included. Download this file if you want a single installation package, and @@ -49,8 +49,8 @@ See the end of the file for license conditions. If you need the C source code at a later date, it will be safe to unpack the source distribution on top of this installation. - + emacs-23.1-barebin-i386.zip - Windows binaries of Emacs-23.1, without lisp code or documentation. + + emacs-24.1-barebin-i386.zip + Windows binaries of Emacs-24.1, without lisp code or documentation. Download this file if you already have the source distribution. @@ -62,12 +62,18 @@ See the end of the file for license conditions. a basic Makefile for compiling with mingw32 and a .def file for generating a DLL with the appropriate exports in addition to the source code to provide the subset of functionality Emacs uses from - libXpm. This corresponds to the libXpm.dll in emacs-23.1-bin-i386.zip - and emacs-23.1-barebin-i386.zip. + libXpm. This corresponds to the libXpm.dll in emacs-24.1-bin-i386.zip + and emacs-24.1-barebin-i386.zip. + +* Prerequisites for running Emacs on Windows 9X + + Using Emacs in GUI mode on Windows 95/98/Me requires the UNICOWS.DLL + dynamic library, which provides MSLU, the Microsoft Unicode Layer + for Windows 9X. You can freely download it from the Microsoft site. * Image support - Emacs 23.1 contains support for images, however for most image formats + Emacs 24.1 contains support for images, however for most image formats supporting libraries are required. This distribution has been tested with the libraries that are distributed with GTK for Windows, and the libraries found at http://gnuwin32.sourceforge.net/. The following image @@ -119,7 +125,7 @@ See the end of the file for license conditions. Distributions for non-x86 platforms are no longer supplied. Older platforms supported by Windows NT no longer seem to be in demand, and Emacs is yet to be ported to 64 bit Windows platforms. If you - are willing to help port Emacs 23 to 64 bit versions of Windows, + are willing to help port Emacs 24 to 64 bit versions of Windows, your contribution will be welcome on the emacs-devel mailing list. * Unpacking distributions @@ -227,7 +233,7 @@ See the end of the file for license conditions. This document serves as an FAQ and a source for further information about the Windows port and related software packages. Note that as most of the information in that FAQ is for earlier versions, so some - information may not be relevant to Emacs-23.1. + information may not be relevant to Emacs-24.1. In addition to the FAQ, there is a mailing list for discussing issues related to the Windows port of Emacs. For information about the diff --git a/nt/ChangeLog b/nt/ChangeLog index 08fd7677077..64b9577e362 100644 --- a/nt/ChangeLog +++ b/nt/ChangeLog @@ -1,3 +1,8 @@ +2011-10-28 Eli Zaretskii + + * README.W32: Mention UNICOWS.DLL as prerequisite for running + Emacs on Windows 9X. + 2011-10-25 Eli Zaretskii * makefile.w32-in (dist): Don't put the top-level INSTALL into the diff --git a/nt/README.W32 b/nt/README.W32 index 4a3f7c41e9e..e4044e409d4 100644 --- a/nt/README.W32 +++ b/nt/README.W32 @@ -50,6 +50,17 @@ See the end of the file for license conditions. directly from a CD or USB flash drive without copying or installing anything on the machine itself. +* Prerequisites for Windows 9X + + To run Emacs on Windows 9X (Windows 95/98/Me), you will need to have + the Microsoft Layer for Unicode (MSLU) installed. It can be + downloaded from the Microsoft site, and comes in a form of a single + dynamic library called UNICOWS.DLL. If this library is not + accessible to Emacs, it will pop up a dialog saying that it cannot + find the library, and will refuse to start up a GUI session. + (However, it is still possible to use Emacs in text mode, even + without UNICOWS.DLL, by invoking it as "emacs -nw", see below.) + * Starting Emacs To run Emacs, simply select Emacs from the Start Menu, or invoke @@ -75,7 +86,9 @@ See the end of the file for license conditions. it will pop up a command prompt window if run directly from Explorer. + runemacs.exe - A wrapper for running Emacs as a GUI application - without popping up a command prompt window. + without popping up a command prompt window. If you create a + desktop shortcut for invoking Emacs, make it point to this + executable, not to emacs.exe. + emacsclient.exe - A command-line client program that can communicate with a running Emacs process. See the `Emacs Server' @@ -98,7 +111,7 @@ See the end of the file for license conditions. + ddeclient.exe - A tool for interacting with DDE servers. - + hexl.exe - A tool for converting files to hex dumps. See the + + hexl.exe - A tool for producing hex dumps of binary files. See the `Editing Binary Files' node of the Emacs manual. + movemail.exe - A helper application for safely moving mail from @@ -194,6 +207,10 @@ See the end of the file for license conditions. truncated to abbrevli.elc, your distribution has been corrupted while unpacking and Emacs will not start. + * On Windows 9X, make sure you have the UNICOWS.DLL library either + in the same directory where you have emacs.exe or in the + directory where system-wide DLLs are kept. + If you believe you have unpacked the distributions correctly and are still encountering problems, see the section on Further Information below. From d3d0842fe219892079cac179ab0843792f29cf1a Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Fri, 28 Oct 2011 23:17:09 +0800 Subject: [PATCH 15/18] * src/xdisp.c (note_mouse_highlight): Fix use of uninitialized var. See: http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg01202.html --- src/ChangeLog | 4 ++++ src/xdisp.c | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 21ec98fa217..da0ba4b11f2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2011-10-28 Chong Yidong + + * xdisp.c (note_mouse_highlight): Fix use of uninitialized var. + 2011-10-28 Dan Nicolaescu * window.c (make_window): Initialize phys_cursor_on_p. diff --git a/src/xdisp.c b/src/xdisp.c index 0757feed1d9..296b2d13219 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -26835,11 +26835,14 @@ note_mouse_highlight (struct frame *f, int x, int y) /* Which window is that in? */ window = window_from_coordinates (f, x, y, &part, 1); - /* If we were displaying active text in another window, clear that. - Also clear if we move out of text area in same window. */ + /* If displaying active text in another window, clear that. */ if (! EQ (window, hlinfo->mouse_face_window) - || (part != ON_TEXT && part != ON_MODE_LINE && part != ON_HEADER_LINE - && !NILP (hlinfo->mouse_face_window))) + /* Also clear if we move out of text area in same window. */ + || (!NILP (hlinfo->mouse_face_window) + && !NILP (window) + && part != ON_TEXT + && part != ON_MODE_LINE + && part != ON_HEADER_LINE)) clear_mouse_face (hlinfo); /* Not on a window -> return. */ From 7e43cfa5ecbbd8886a334fe97b1bf3f8ea661e52 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Fri, 28 Oct 2011 15:24:05 +0000 Subject: [PATCH 16/18] Add and entry to ChangeLog. --- lisp/ChangeLog | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4ac4419b163..1e0f5d0487a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,30 @@ +2011-10-28 Alan Mackenzie + + Amend the handling of c-beginning/end-of-defun in nested declaration + scopes. + + * cc-vars.el (c-defun-tactic): Move here from cc-langs.el. Change it to a + defcustom. + + * cc-mode.texi (Movement Commands): Document `c-defun-tactic'. Document + the new handling of nested scopes for movement by defuns. + + * cc-langs.el (c-defun-tactic): Move this variable to cc-vars.el. + (c-nonlabel-token-2-key): New variable for change in cc-engine.el. + + * cc-engine.el (c-beginning-of-statement-1): Prevent "class foo : bar" + being spuriously recognized as a label. + + * cc-cmds.el (c-narrow-to-most-enclosing-decl-block): Add parameter + `inclusive' (to include enclosing braces in the region). + (c-widen-to-enclosing-decl-scope): New function. + (c-while-widening-to-decl-block): New macro. + (c-beginning-of-defun, c-end-of-defun): Change algorithm to keep going + outward for defun boundaries, and correspondingly change symbol + `respect-enclosure' to `go-outward'. + (c-declaration-limits): Change algorithm to report only the "innermost" + defun's boundaries. + 2011-10-28 Deniz Dogan * net/rcirc.el (rcirc-mode): Use hard newlines. From 52bedd34385bf6434d60d884b306e5883fb656d9 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Fri, 28 Oct 2011 16:16:02 +0000 Subject: [PATCH 17/18] Increment c-version to 5.32.2. --- doc/misc/ChangeLog | 12 +++++++++ lisp/ChangeLog | 54 ++++++++++++++++++--------------------- lisp/progmodes/cc-defs.el | 2 +- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index 6b0ef9c5d8b..10a0d5e7a91 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog @@ -1,3 +1,15 @@ +2011-10-28 Alan Mackenzie + + * cc-mode.texi (Indentation Commands): Mention "macros with semicolons". + (Other Special Indentations): Add an xref to "Macros with ;". + (Customizing Macros): Add stuff about syntax in macros. Add an xref to + "Macros with ;". + (Macros with ;): New page. + + * progmodes/cc-mode.texi (Movement Commands): Document + `c-defun-tactic'. Document the new handling of nested scopes for + movement by defuns. + 2011-10-23 Michael Albinus Sync with Tramp 2.2.3. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1e0f5d0487a..44f39383139 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,22 +1,25 @@ +2011-10-28 Alan Mackenzie + + * progmodes/cc-defs.el (c-version). -> 5.32.2. + 2011-10-28 Alan Mackenzie Amend the handling of c-beginning/end-of-defun in nested declaration scopes. - * cc-vars.el (c-defun-tactic): Move here from cc-langs.el. Change it to a - defcustom. + * progmodes/cc-vars.el (c-defun-tactic): Move here from + cc-langs.el. Change it to a defcustom. - * cc-mode.texi (Movement Commands): Document `c-defun-tactic'. Document - the new handling of nested scopes for movement by defuns. - - * cc-langs.el (c-defun-tactic): Move this variable to cc-vars.el. + * progmodes/cc-langs.el (c-defun-tactic): Move this variable to + cc-vars.el. (c-nonlabel-token-2-key): New variable for change in cc-engine.el. - * cc-engine.el (c-beginning-of-statement-1): Prevent "class foo : bar" - being spuriously recognized as a label. + * progmodes/cc-engine.el (c-beginning-of-statement-1): Prevent + "class foo : bar" being spuriously recognized as a label. - * cc-cmds.el (c-narrow-to-most-enclosing-decl-block): Add parameter - `inclusive' (to include enclosing braces in the region). + * progmodes/cc-cmds.el (c-narrow-to-most-enclosing-decl-block): + Add parameter `inclusive' (to include enclosing braces in the + region). (c-widen-to-enclosing-decl-scope): New function. (c-while-widening-to-decl-block): New macro. (c-beginning-of-defun, c-end-of-defun): Change algorithm to keep going @@ -34,39 +37,32 @@ Amend to indent and fontify macros "which include their own semicolon" correctly, using the "virtual semicolon" mechanism. - * cc-defs.el: Update "virtual semicolon" comments. + * progmodes/cc-defs.el: Update "virtual semicolon" comments. - * cc-engine.el (c-crosses-statement-barrier-p): Recoded to scan one line at - at time rather than having \n and \r explicitly in c-stmt-delim-chars + * progmodes/cc-engine.el (c-crosses-statement-barrier-p): Recoded + to scan one line at at time rather than having \n and \r + explicitly in c-stmt-delim-chars (for some modes, e.g. AWK). (c-forward-label): Amend for virtual semicolons. (c-at-macro-vsemi-p, c-macro-vsemi-status-unknown-p): New functions - * cc-fonts.el (c-font-lock-declarations): Take account of the new C macros. + * progmodes/cc-fonts.el (c-font-lock-declarations): Take account + of the new C macros. - * cc-langs.el (c-at-vsemi-p-fn, c-vsemi-status-unknown-p-fn): move to - earlier in the file. + * progmodes/cc-langs.el (c-at-vsemi-p-fn): + (c-vsemi-status-unknown-p-fn): move to earlier in the file. (c-opt-cpp-symbol, c-line-comment-start-regexp): New language variables. (c-opt-cpp-macro-define): Make into a full language variable. (c-stmt-delim-chars, c-stmt-delim-chars-with-comma): Special value for AWK Mode (including \n, \r) removed, no longer needed. - * cc-mode.el (c-mode, c++-mode, objc-mode): Invoke - c-make-macro-with-semi-re. (Erroneously committed early, in previous - version, 5.259.) + * progmodes/cc-mode.el (c-mode, c++-mode, objc-mode): Invoke + c-make-macro-with-semi-re. - * cc-vars.el (c-macro-with-semi-re, c-macro-names-with-semicolon): New - variables. + * progmodes/cc-vars.el (c-macro-with-semi-re): + (c-macro-names-with-semicolon): New variables. (c-make-macro-with-semi-re): New function - * cc-mode.texi (Indentation Commands): Mention "macros with semicolons". - (Other Special Indentations): Add an xref to "Macros with ;". - (Customizing Macros): Add stuff about syntax in macros. Add an xref to - "Macros with ;". - (Macros with ;): New page. - - - 2011-10-28 Stefan Monnier * vc/log-edit.el: Fill empty field rather than adding new one. diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index 93da6e3e2be..8632807f2b8 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el @@ -93,7 +93,7 @@ ;;; Variables also used at compile time. -(defconst c-version "5.31.9" +(defconst c-version "5.32.2" "CC Mode version number.") (defconst c-version-sym (intern c-version)) From 5a7a728bb736ee9beea6c30514e0dc95c966de13 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 28 Oct 2011 20:41:09 +0200 Subject: [PATCH 18/18] Fix use of uninitialized variable. src/xdisp.c (note_mouse_highlight): Initialize `part', to avoid a possible random value that matches one of those tested as condition to clear the mouse face. --- src/ChangeLog | 6 ++++++ src/xdisp.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index da0ba4b11f2..fad9b4f9e46 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2011-10-28 Eli Zaretskii + + * xdisp.c (note_mouse_highlight): Initialize `part', to avoid a + possible random value that matches one of those tested as + condition to clear the mouse face. + 2011-10-28 Chong Yidong * xdisp.c (note_mouse_highlight): Fix use of uninitialized var. diff --git a/src/xdisp.c b/src/xdisp.c index 296b2d13219..22f7c2bbd26 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -26801,7 +26801,7 @@ void note_mouse_highlight (struct frame *f, int x, int y) { Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); - enum window_part part; + enum window_part part = ON_NOTHING; Lisp_Object window; struct window *w; Cursor cursor = No_Cursor;