From: Eli Zaretskii Date: Tue, 22 Mar 2016 00:42:35 +0000 (-0700) Subject: Fix problems caused by new implementation of sub-word mode X-Git-Url: https://code.delx.au/gnu-emacs/commitdiff_plain/7dba17670f42cdaa73424a2bf60925ef49671fad Fix problems caused by new implementation of sub-word mode * lisp/subr.el (forward-word-strictly, backward-word-strictly): New functions. (word-move-empty-char-table): New variable. * etc/NEWS: Mention 'forward-word-strictly' and 'backward-word-strictly'. * doc/lispref/positions.texi (Word Motion): Document 'find-word-boundary-function-table', 'forward-word-strictly', and 'backward-word-strictly'. (Bug#22560) * src/syntax.c (syms_of_syntax) : Doc fix. * lisp/wdired.el (wdired-xcase-word): * lisp/textmodes/texnfo-upd.el (texinfo-copy-node-name) (texinfo-copy-section-title, texinfo-start-menu-description) (texinfo-copy-menu-title, texinfo-specific-section-type) (texinfo-insert-node-lines, texinfo-copy-next-section-title): * lisp/textmodes/texinfo.el (texinfo-clone-environment) (texinfo-insert-@end): * lisp/textmodes/texinfmt.el (texinfo-format-scan) (texinfo-anchor, texinfo-multitable-widths) (texinfo-multitable-item): * lisp/textmodes/tex-mode.el (latex-env-before-change): * lisp/textmodes/flyspell.el (texinfo-mode-flyspell-verify): * lisp/skeleton.el (skeleton-insert): * lisp/simple.el (count-words): * lisp/progmodes/vhdl-mode.el (vhdl-beginning-of-libunit) (vhdl-beginning-of-defun, vhdl-beginning-of-statement-1) (vhdl-update-sensitivity-list, vhdl-template-block) (vhdl-template-break, vhdl-template-case, vhdl-template-default) (vhdl-template-default-indent, vhdl-template-for-loop) (vhdl-template-if-then-use, vhdl-template-bare-loop) (vhdl-template-nature, vhdl-template-procedural) (vhdl-template-process, vhdl-template-selected-signal-asst) (vhdl-template-type, vhdl-template-variable) (vhdl-template-while-loop, vhdl-beginning-of-block) (vhdl-hooked-abbrev, vhdl-port-copy, vhdl-hs-forward-sexp-func): * lisp/progmodes/verilog-mode.el (verilog-backward-sexp) (verilog-forward-sexp, verilog-beg-of-statement) (verilog-set-auto-endcomments, verilog-backward-token) (verilog-do-indent): * lisp/progmodes/vera-mode.el (vera-guess-basic-syntax) (vera-indent-block-closing): * lisp/progmodes/simula.el (simula-context) (simula-backward-up-level, simula-forward-down-level) (simula-previous-statement, simula-next-statement) (simula-skip-comment-backward, simula-calculate-indent) (simula-find-if, simula-electric-keyword): * lisp/progmodes/sh-script.el (sh-smie--rc-newline-semi-p): * lisp/progmodes/ruby-mode.el (ruby-smie--redundant-do-p) (ruby-smie--forward-token, ruby-smie--backward-token) (ruby-singleton-class-p, ruby-calculate-indent) (ruby-forward-sexp, ruby-backward-sexp): * lisp/progmodes/ps-mode.el (ps-run-goto-error): * lisp/progmodes/perl-mode.el (perl-syntax-propertize-function) (perl-syntax-propertize-special-constructs) (perl-backward-to-start-of-continued-exp): * lisp/progmodes/pascal.el (pascal-indent-declaration): * lisp/progmodes/octave.el (octave-function-file-p): * lisp/progmodes/mantemp.el (mantemp-insert-cxx-syntax): * lisp/progmodes/js.el (js--forward-function-decl): * lisp/progmodes/idlwave.el (idlwave-show-begin-check) (idlwave-beginning-of-block, idlwave-end-of-block) (idlwave-block-jump-out, idlwave-determine-class): * lisp/progmodes/icon.el (icon-is-continuation-line) (icon-backward-to-start-of-continued-exp, end-of-icon-defun): * lisp/progmodes/hideif.el (hide-ifdef-define): * lisp/progmodes/f90.el (f90-change-keywords): * lisp/progmodes/cperl-mode.el (cperl-electric-pod) (cperl-linefeed, cperl-electric-terminator) (cperl-find-pods-heres, cperl-fix-line-spacing) (cperl-invert-if-unless): * lisp/progmodes/cc-engine.el (c-forward-<>-arglist-recur): * lisp/progmodes/cc-align.el (c-lineup-java-inher): * lisp/progmodes/ada-mode.el (ada-compile-goto-error) (ada-adjust-case-skeleton, ada-create-case-exception) (ada-create-case-exception-substring) (ada-case-read-exceptions-from-file, ada-after-keyword-p) (ada-scan-paramlist, ada-get-current-indent, ada-get-indent-end) (ada-get-indent-if, ada-get-indent-block-start) (ada-get-indent-loop, ada-get-indent-type) (ada-search-prev-end-stmt, ada-check-defun-name) (ada-goto-decl-start, ada-goto-matching-start) (ada-goto-matching-end, ada-looking-at-semi-or) (ada-looking-at-semi-private, ada-in-paramlist-p) (ada-search-ignore-complex-boolean, ada-move-to-start) (ada-move-to-end, ada-which-function, ada-gen-treat-proc): * lisp/net/quickurl.el (quickurl-grab-url): * lisp/mail/sendmail.el (mail-do-fcc): * lisp/mail/rmail.el (rmail-resend): * lisp/mail/mailabbrev.el (mail-abbrev-complete-alias): * lisp/mail/mail-extr.el (mail-extract-address-components): * lisp/json.el (json-read-keyword): * lisp/files.el (insert-directory): * lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine): * lisp/completion.el (symbol-under-point, symbol-before-point) (symbol-before-point-for-complete, next-cdabbrev) (add-completions-from-c-buffer): * lisp/cedet/semantic/texi.el (semantic-up-context) (semantic-beginning-of-context): * lisp/cedet/semantic/bovine/el.el (semantic-get-local-variables): use 'forward-word-strictly' and 'backward-word-strictly' instead of 'forward-word' and 'backward-word'. [This reapplies commit c1d32a65372c72d7de4808d620eefd3214a8e92a, which was inadvertently lost by merge commit c71e7cc113ed0d5f01aaa2e441a3e3c9fbeb9fa5.] --- diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi index b88e76e823..1d748b8752 100644 --- a/doc/lispref/positions.texi +++ b/doc/lispref/positions.texi @@ -191,18 +191,25 @@ in the opposite direction. @node Word Motion @subsection Motion by Words - These functions for parsing words use the syntax table to decide -whether a given character is part of a word. @xref{Syntax Tables}. + The functions for parsing words described below use the syntax table +to decide whether a given character is part of a word. @xref{Syntax +Tables}. @deffn Command forward-word &optional count This function moves point forward @var{count} words (or backward if @var{count} is negative). If @var{count} is omitted or @code{nil}, it -defaults to 1. +defaults to 1. In an interactive call, @var{count} is specified by +the numeric prefix argument. ``Moving one word'' means moving until point crosses a -word-constituent character and then encounters a word-separator -character. However, this function cannot move point past the boundary -of the accessible portion of the buffer, or across a field boundary +word-constituent character, which indicates the beginning of a word, +and then continue moving until the word ends. By default, characters +that begin and end words, known as @dfn{word boundaries}, are defined +by the current buffer's syntax table (@pxref{Syntax Class Table}), but +modes can override that by setting up a suitable +@code{find-word-boundary-function-table}, described below. In any +case, this function cannot move point past the boundary of the +accessible portion of the buffer, or across a field boundary (@pxref{Fields}). The most common case of a field boundary is the end of the prompt in the minibuffer. @@ -214,8 +221,6 @@ the buffer boundary or field boundary. If @code{inhibit-field-text-motion} is non-@code{nil}, this function ignores field boundaries. -In an interactive call, @var{count} is specified by the numeric prefix -argument. @end deffn @deffn Command backward-word &optional count @@ -225,10 +230,10 @@ backward until encountering the front of a word, rather than forward. @defopt words-include-escapes @c Emacs 19 feature -This variable affects the behavior of @code{forward-word} and everything -that uses it. If it is non-@code{nil}, then characters in the -escape and character-quote syntax classes count as part of -words. Otherwise, they do not. +This variable affects the behavior of @code{forward-word} and +@code{backward-word}, and everything that uses them. If it is +non-@code{nil}, then characters in the escape and character-quote +syntax classes count as part of words. Otherwise, they do not. @end defopt @defvar inhibit-field-text-motion @@ -237,6 +242,37 @@ If this variable is non-@code{nil}, certain motion functions including @code{forward-paragraph} ignore field boundaries. @end defvar +@defvar find-word-boundary-function-table +This variable affects the behavior of @code{forward-word} and +@code{backward-word}, and everything that uses them. Its value is a +char-table (@pxref{Char-Tables}) of functions to search for word +boundaries. If a character has a non-@code{nil} entry in this table, +then when a word starts or ends with that character, the corresponding +function will be called with 2 arguments: @var{pos} and @var{limit}. +The function should return the position of the other word boundary. +Specifically, if @var{pos} is smaller than @var{limit}, then @var{pos} +is at the beginning of a word, and the function should return the +position after the last character of the word; otherwise, @var{pos} is +at the last character of a word, and the function should return the +position of that word's first character. +@end defvar + +@defun forward-word-strictly &optional count +This function is like @code{forward-word}, but it is not affected by +@code{find-word-boundary-function-table}. Lisp programs that should +not change behavior when word movement is modified by modes which set +that table, such as @code{subword-mode}, should use this function +instead of @code{forward-word}. +@end defun + +@defun backward-word-strictly &optional count +This function is like @code{backward-word}, but it is not affected by +@code{find-word-boundary-function-table}. Like with +@code{forward-word-strictly}, use this function instead of +@code{backward-word} when movement by words should only consider +syntax tables. +@end defun + @node Buffer End Motion @subsection Motion to an End of the Buffer @cindex move to beginning or end of buffer diff --git a/etc/NEWS b/etc/NEWS index 57bd110116..4414625eac 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1629,6 +1629,14 @@ eliminated. Removed font-lock-beginning-of-syntax-function and the SYNTAX-BEGIN slot in font-lock-defaults. ++++ +** The new implementation of Subword mode affects word movement everywhere. +When Subword mode is turned on, `forward-word', `backward-word', and +everything that uses them will move by sub-words, effectively +overriding the buffer's syntax table. Lisp programs that shouldn't be +affected by Subword mode should call the new functions +`forward-word-strictly' and `backward-word-strictly' instead. + +++ ** `package-initialize' now sets `package-enable-at-startup' to nil if called during startup. Users who call this function in their init diff --git a/lisp/cedet/semantic/bovine/el.el b/lisp/cedet/semantic/bovine/el.el index 7824942d96..6f41ba3064 100644 --- a/lisp/cedet/semantic/bovine/el.el +++ b/lisp/cedet/semantic/bovine/el.el @@ -700,7 +700,7 @@ of `let' or `let*', grab those variable names." ;; Snart args... (up-list -1) (forward-char 1) - (forward-word 1) + (forward-word-strictly 1) (skip-chars-forward "* \t\n") (let ((arglst (read (buffer-substring-no-properties (point) diff --git a/lisp/cedet/semantic/texi.el b/lisp/cedet/semantic/texi.el index 8b4f6f4e14..cbb7705f9d 100644 --- a/lisp/cedet/semantic/texi.el +++ b/lisp/cedet/semantic/texi.el @@ -258,7 +258,7 @@ can handle the @menu environment.") (when (not parenthetical) ;; We are in parentheses. Are they the types of parens ;; belonging to a texinfo construct? - (forward-word -1) + (forward-word-strictly -1) (when (looking-at "@\\w+{") (setq done (point)))))) ;; If we are not in a parenthetical node, then find a block instead. @@ -287,7 +287,7 @@ can handle the @menu environment.") ;; If we can't go up, we can't do this either. t ;; We moved, so now we need to skip into whatever this thing is. - (forward-word 1) ;; skip the command + (forward-word-strictly 1) ;; skip the command (if (looking-at "\\s-*{") ;; In a short command. Go in. (down-list 1) diff --git a/lisp/completion.el b/lisp/completion.el index 0659421710..093740d2cc 100644 --- a/lisp/completion.el +++ b/lisp/completion.el @@ -542,13 +542,13 @@ But only if it is longer than `completion-min-length'." ;; Remove chars to ignore at the start. (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w) (goto-char cmpl-symbol-start) - (forward-word 1) + (forward-word-strictly 1) (setq cmpl-symbol-start (point)) (goto-char saved-point))) ;; Remove chars to ignore at the end. (cond ((= (char-syntax (char-after (1- cmpl-symbol-end))) ?w) (goto-char cmpl-symbol-end) - (forward-word -1) + (forward-word-strictly -1) (setq cmpl-symbol-end (point)) (goto-char saved-point))) ;; Return completion if the length is reasonable. @@ -584,7 +584,7 @@ Returns nil if there isn't one longer than `completion-min-length'." ;; Remove chars to ignore at the start. (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w) (goto-char cmpl-symbol-start) - (forward-word 1) + (forward-word-strictly 1) (setq cmpl-symbol-start (point)) (goto-char cmpl-symbol-end))) ;; Return value if long enough. @@ -597,12 +597,12 @@ Returns nil if there isn't one longer than `completion-min-length'." (let ((saved-point (point))) (setq cmpl-symbol-start (scan-sexps saved-point -1)) ;; take off chars. from end - (forward-word -1) + (forward-word-strictly -1) (setq cmpl-symbol-end (point)) ;; remove chars to ignore at the start (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w) (goto-char cmpl-symbol-start) - (forward-word 1) + (forward-word-strictly 1) (setq cmpl-symbol-start (point)))) ;; Restore state. (goto-char saved-point) @@ -653,7 +653,7 @@ Returns nil if there isn't one longer than `completion-min-length'." ;; Remove chars to ignore at the start. (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w) (goto-char cmpl-symbol-start) - (forward-word 1) + (forward-word-strictly 1) (setq cmpl-symbol-start (point)) (goto-char cmpl-symbol-end))) ;; Return completion if the length is reasonable. @@ -821,7 +821,7 @@ This is sensitive to `case-fold-search'." ;; symbol char to ignore at end. Are we at end ? (progn (setq saved-point-2 (point)) - (forward-word -1) + (forward-word-strictly -1) (prog1 (= (char-syntax (preceding-char)) ? ) (goto-char saved-point-2))))) @@ -1850,7 +1850,7 @@ Prefix args :: (cond ((looking-at "\\(define\\|ifdef\\)\\>") ;; skip forward over definition symbol ;; and add it to database - (and (forward-word 2) + (and (forward-word-strictly 2) (setq string (symbol-before-point)) ;;(push string foo) (add-completion-to-tail-if-new string))))) @@ -1868,7 +1868,7 @@ Prefix args :: ;; move to next separator char. (goto-char (setq next-point (scan-sexps (point) 1)))) - (forward-word -1) + (forward-word-strictly -1) ;; add to database (if (setq string (symbol-under-point)) ;; (push string foo) @@ -1876,7 +1876,7 @@ Prefix args :: ;; Local TMC hack (useful for parsing paris.h) (if (and (looking-at "_AP") ;; "ansi prototype" (progn - (forward-word -1) + (forward-word-strictly -1) (setq string (symbol-under-point)))) (add-completion-to-tail-if-new string))) diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index e93294d6cc..3a81adeb6a 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el @@ -1580,7 +1580,7 @@ mouse-[0-3]\\)\\)\\>")) (if (and sym (boundp sym) (fboundp sym) (save-excursion (goto-char mb) - (forward-word -1) + (forward-word-strictly -1) (not (looking-at "variable\\|option\\|function\\|command\\|symbol")))) (if (checkdoc-autofix-ask-replace @@ -1596,7 +1596,7 @@ mouse-[0-3]\\)\\)\\>")) nil t nil nil "variable"))) (goto-char (1- mb)) (insert disambiguate " ") - (forward-word 1)) + (forward-word-strictly 1)) (setq ret (format "Disambiguate %s by preceding w/ \ function,command,variable,option or symbol." ms1)))))) diff --git a/lisp/files.el b/lisp/files.el index bd9792a51a..d5b34af86b 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6568,7 +6568,7 @@ normally equivalent short `-D' option is just passed on to (setq error-lines (nreverse error-lines)) ;; Now read the numeric positions of file names. (goto-char linebeg) - (forward-word 1) + (forward-word-strictly 1) (forward-char 3) (while (< (point) end) (let ((start (insert-directory-adj-pos diff --git a/lisp/json.el b/lisp/json.el index bd1ee53165..1eabe0fa33 100644 --- a/lisp/json.el +++ b/lisp/json.el @@ -296,14 +296,14 @@ KEYWORD is the keyword expected." (unless (char-equal char (json-peek)) (signal 'json-unknown-keyword (list (save-excursion - (backward-word 1) + (backward-word-strictly 1) (thing-at-point 'word))))) (json-advance)) keyword) (unless (looking-at "\\(\\s-\\|[],}]\\|$\\)") (signal 'json-unknown-keyword (list (save-excursion - (backward-word 1) + (backward-word-strictly 1) (thing-at-point 'word))))) (cond ((string-equal keyword "true") t) ((string-equal keyword "false") json-false) diff --git a/lisp/mail/mail-extr.el b/lisp/mail/mail-extr.el index 9dc3af6ab6..4f3e71d34b 100644 --- a/lisp/mail/mail-extr.el +++ b/lisp/mail/mail-extr.el @@ -880,7 +880,7 @@ consing a string.)" (and (not (eobp)) (eq ?w (char-syntax (char-after))) (progn - (forward-word 1) + (forward-word-strictly 1) (and (not (eobp)) (> (char-after) ?\177) (not (eq (char-after) ? ))))))))) @@ -1312,7 +1312,7 @@ consing a string.)" ) (t (setq atom-beg (point)) - (forward-word 1) + (forward-word-strictly 1) (setq atom-end (point)) (goto-char atom-beg) (save-restriction diff --git a/lisp/mail/mailabbrev.el b/lisp/mail/mailabbrev.el index ed6a74349f..a047f5f000 100644 --- a/lisp/mail/mailabbrev.el +++ b/lisp/mail/mailabbrev.el @@ -574,7 +574,7 @@ of a mail alias. The value is set up, buffer-local, when first needed.") (let ((end (point)) (beg (with-syntax-table mail-abbrev-syntax-table (save-excursion - (backward-word 1) + (backward-word-strictly 1) (point))))) (completion-in-region beg end mail-abbrevs))) diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 29926108c1..5c2331aea4 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el @@ -4089,7 +4089,7 @@ typically for purposes of moderating a list." (set-syntax-table mail-abbrev-syntax-table) (goto-char before) (while (and (< (point) end) - (progn (forward-word 1) + (progn (forward-word-strictly 1) (<= (point) end))) (expand-abbrev)) (set-syntax-table old-syntax-table)) diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el index 5ab5bd9a2c..58f708a0c1 100644 --- a/lisp/mail/sendmail.el +++ b/lisp/mail/sendmail.el @@ -1404,7 +1404,7 @@ just append to the file, in Babyl format if necessary." (insert "\nFrom " (user-login-name) " " (current-time-string time) "\n") ;; Insert the time zone before the year. (forward-char -1) - (forward-word -1) + (forward-word-strictly -1) (require 'mail-utils) (insert (mail-rfc822-time-zone time) " ") (goto-char (point-max)) diff --git a/lisp/net/quickurl.el b/lisp/net/quickurl.el index 7a46485531..bb9ce31307 100644 --- a/lisp/net/quickurl.el +++ b/lisp/net/quickurl.el @@ -347,7 +347,7 @@ It is assumed that the URL is either \"unguarded\" or is wrapped inside an ;; need to do a little more work to get to where we want to be. (when (thing-at-point-looking-at thing-at-point-markedup-url-regexp) (search-backward "") - (forward-word 1) + (forward-word-strictly 1) (ada-goto-next-non-ws)) ;; read type of parameter @@ -2472,7 +2476,7 @@ and the offset." (forward-comment -1000) (if (= (char-before) ?\)) (forward-sexp -1) - (forward-word -1)) + (forward-word-strictly -1)) ;; If there is a parameter list, and we have a function declaration ;; or a access to subprogram declaration @@ -2480,26 +2484,26 @@ and the offset." (if (and (= (following-char) ?\() (save-excursion (or (progn - (backward-word 1) + (backward-word-strictly 1) (looking-at "\\(function\\|procedure\\)\\>")) (progn - (backward-word 1) + (backward-word-strictly 1) (setq num-back 2) (looking-at "\\(function\\|procedure\\)\\>"))))) ;; The indentation depends of the value of ada-indent-return (if (<= (eval var) 0) (list (point) (list '- var)) - (list (progn (backward-word num-back) (point)) + (list (progn (backward-word-strictly num-back) (point)) var)) ;; Else there is no parameter list, but we have a function ;; Only do something special if the user want to indent ;; relative to the "function" keyword (if (and (> (eval var) 0) - (save-excursion (forward-word -1) + (save-excursion (forward-word-strictly -1) (looking-at "function\\>"))) - (list (progn (forward-word -1) (point)) var) + (list (progn (forward-word-strictly -1) (point)) var) ;; Else... (ada-indent-on-previous-lines nil orgpoint orgpoint))))))) @@ -2600,7 +2604,7 @@ and the offset." ;; avoid "with procedure"... in generic parts (save-excursion - (forward-word -1) + (forward-word-strictly -1) (setq found (not (looking-at "with")))))) (cond @@ -2759,7 +2763,7 @@ ORGPOINT is the limit position used in the calculation." ;; yes, look what's following 'end' (progn - (forward-word 1) + (forward-word-strictly 1) (ada-goto-next-non-ws) (cond ;; @@ -2776,7 +2780,7 @@ ORGPOINT is the limit position used in the calculation." (save-excursion (ada-check-matching-start (match-string 0)) ;; we are now looking at the matching "record" statement - (forward-word 1) + (forward-word-strictly 1) (ada-goto-stmt-start) ;; now on the matching type declaration, or use clause (unless (looking-at "\\(for\\|type\\)\\>") @@ -2891,7 +2895,7 @@ ORGPOINT is the limit position used in the calculation." (looking-at "\\")) (setq cur-indent (save-excursion (back-to-indentation) (point)))) ;; skip 'then' - (forward-word 1) + (forward-word-strictly 1) (list cur-indent 'ada-indent)) (list cur-indent 'ada-broken-indent)))) @@ -2902,7 +2906,7 @@ ORGPOINT is the limit position used in the calculation." (let ((pos nil)) (cond ((save-excursion - (forward-word 1) + (forward-word-strictly 1) (setq pos (ada-goto-next-non-ws orgpoint))) (goto-char pos) (save-excursion @@ -3141,8 +3145,8 @@ ORGPOINT is the limit position used in the calculation." (and (goto-char (match-end 0)) (ada-goto-next-non-ws orgpoint) - (forward-word 1) - (if (= (char-after) ?') (forward-word 1) t) + (forward-word-strictly 1) + (if (= (char-after) ?') (forward-word-strictly 1) t) (ada-goto-next-non-ws orgpoint) (looking-at "\\") ;; @@ -3224,7 +3228,7 @@ ORGPOINT is the limit position used in the calculation." "end" nil orgpoint nil 'word-search-forward)) (ada-goto-next-non-ws) (looking-at "\\") - (forward-word 1) + (forward-word-strictly 1) (ada-goto-next-non-ws) (= (char-after) ?\;))) (goto-char (car match-dat)) @@ -3334,7 +3338,7 @@ is the end of the match." (save-excursion (ada-goto-previous-word) (looking-at "\\<\\(end\\|or\\|and\\)\\>[ \t]*[^;]"))) - (forward-word -1)) + (forward-word-strictly -1)) ((looking-at "is") (setq found @@ -3355,7 +3359,7 @@ is the end of the match." ((looking-at "private") (save-excursion - (backward-word 1) + (backward-word-strictly 1) (setq found (not (looking-at "is"))))) (t @@ -3459,18 +3463,18 @@ Moves point to the beginning of the declaration." (if (looking-at "\\") (progn (forward-comment -1) - (backward-word 1)) + (backward-word-strictly 1)) ;; ;; no, => 'procedure'/'function'/'task'/'protected' ;; (progn - (forward-word 2) - (backward-word 1) + (forward-word-strictly 2) + (backward-word-strictly 1) ;; ;; skip 'body' 'type' ;; (if (looking-at "\\<\\(body\\|type\\)\\>") - (forward-word 1)) + (forward-word-strictly 1)) (forward-sexp 1) (backward-sexp 1))) ;; @@ -3566,7 +3570,7 @@ otherwise throw error." ;; ((looking-at "if") (save-excursion - (forward-word -1) + (forward-word-strictly -1) (unless (looking-at "\\") (progn (setq nest-count (1- nest-count)) @@ -3636,7 +3640,7 @@ otherwise throw error." ;; ((looking-at "when") (save-excursion - (forward-word -1) + (forward-word-strictly -1) (unless (looking-at "\\") (progn (if stop-at-when @@ -3687,7 +3691,7 @@ If GOTOTHEN is non-nil, point moves to the `then' following `if'." (unless (and (looking-at "\\") (save-excursion - (forward-word -1) + (forward-word-strictly -1) (looking-at "\\"))) (progn ;; calculate nest-depth @@ -3739,7 +3743,7 @@ If GOTOTHEN is non-nil, point moves to the `then' following `if'." (number-to-string (count-lines 1 (1+ current))))))) (unless (looking-at "renames") (progn - (forward-word 1) + (forward-word-strictly 1) (ada-goto-next-non-ws) ;; ignore it if it is only a declaration with 'new' ;; We could have package Foo is new .... @@ -3755,13 +3759,13 @@ If GOTOTHEN is non-nil, point moves to the `then' following `if'." ;; found task start => check if it has a body ((looking-at "task") (save-excursion - (forward-word 1) + (forward-word-strictly 1) (ada-goto-next-non-ws) (cond ((looking-at "\\")) ((looking-at "\\") ;; In that case, do nothing if there is a "is" - (forward-word 2);; skip "type" + (forward-word-strictly 2);; skip "type" (ada-goto-next-non-ws);; skip type name ;; Do nothing if we are simply looking at a simple @@ -3781,7 +3785,7 @@ If GOTOTHEN is non-nil, point moves to the `then' following `if'." (t ;; Check if that task declaration had a block attached to ;; it (i.e do nothing if we have just "task name;") - (unless (progn (forward-word 1) + (unless (progn (forward-word-strictly 1) (looking-at "[ \t]*;")) (setq nest-count (1- nest-count)))))) (setq last-was-begin (cdr last-was-begin)) @@ -3906,7 +3910,7 @@ If NOERROR is non-nil, it only returns nil if no matching start found." ;; ;; calculate nest-depth ;; - (backward-word 1) + (backward-word-strictly 1) (cond ;; procedures and functions need to be processed recursively, in ;; case they are defined in a declare/begin block, as in: @@ -3925,7 +3929,7 @@ If NOERROR is non-nil, it only returns nil if no matching start found." ((and (looking-at "\\")) (if first - (forward-word 1) + (forward-word-strictly 1) (setq pos (point)) (ada-search-ignore-string-comment "is\\|;") @@ -3946,7 +3950,7 @@ If NOERROR is non-nil, it only returns nil if no matching start found." (skip-chars-forward "end") (ada-goto-next-non-ws) (looking-at "\\<\\(loop\\|select\\|record\\|case\\|if\\)\\>")) - (forward-word 1))) + (forward-word-strictly 1))) ;; found package start => check if it really starts a block, and is not ;; in fact a generic instantiation for instance @@ -3965,7 +3969,7 @@ If NOERROR is non-nil, it only returns nil if no matching start found." (if (not first) (setq nest-count (1+ nest-count))) (setq found (<= nest-count 0)) - (forward-word 1))) ; end of 'cond' + (forward-word-strictly 1))) ; end of 'cond' (setq first nil)) @@ -4077,7 +4081,7 @@ Assumes point to be at the end of a statement." (save-excursion (and (looking-at "\\") (progn - (forward-word 1) + (forward-word-strictly 1) (ada-goto-stmt-start) (looking-at "\\"))))) @@ -4100,7 +4104,7 @@ Return nil if the private is part of the package name, as in (progn (forward-comment -1000) (and (not (bobp)) (or (= (char-before) ?\;) - (and (forward-word -3) + (and (forward-word-strictly -3) (looking-at "\\")))))))) @@ -4120,11 +4124,11 @@ Return nil if the private is part of the package name, as in (skip-chars-backward " \t\n") (if (= (char-before) ?\") (backward-char 3) - (backward-word 1)) + (backward-word-strictly 1)) t) ;; and now over the second one - (backward-word 1) + (backward-word-strictly 1) ;; We should ignore the case when the reserved keyword is in a ;; comment (for instance, when we have: @@ -4150,7 +4154,7 @@ Return nil if the private is part of the package name, as in If BACKWARDP is non-nil, search backward; search forward otherwise." (let (result) (while (and (setq result (ada-search-ignore-string-comment regexp backwardp)) - (save-excursion (forward-word -1) + (save-excursion (forward-word-strictly -1) (looking-at "and then\\|or else")))) result)) @@ -4343,9 +4347,9 @@ of the region. Otherwise, operate only on the current line." (ada-in-string-or-comment-p) (and (progn (or (looking-at "[ \t]*\\") - (backward-word 1)) + (backward-word-strictly 1)) (or (looking-at "[ \t]*\\") - (backward-word 1)) + (backward-word-strictly 1)) (or (looking-at "[ \t]*\\") (error "Not on end ...;"))) (ada-goto-matching-start 1) @@ -4399,7 +4403,7 @@ Moves to `begin' if in a declarative part." ((save-excursion (and (ada-goto-stmt-start) (looking-at "\\" ) - (forward-word 1) + (forward-word-strictly 1) (ada-goto-next-non-ws) (looking-at "\\"))) (ada-search-ignore-string-comment "begin" nil nil nil @@ -5020,7 +5024,7 @@ Since the search can be long, the results are cached." (skip-chars-forward " \t\n") (if (looking-at "return") (progn - (forward-word 1) + (forward-word-strictly 1) (skip-chars-forward " \t\n") (skip-chars-forward "a-zA-Z0-9_'"))) @@ -5271,8 +5275,8 @@ for `ada-procedure-start-regexp'." ((or (looking-at "^[ \t]*procedure") (setq func-found (looking-at "^[ \t]*function"))) ;; treat it as a proc/func - (forward-word 2) - (forward-word -1) + (forward-word-strictly 2) + (forward-word-strictly -1) (setq procname (buffer-substring (point) (cdr match))) ; store proc name ;; goto end of procname @@ -5285,7 +5289,7 @@ for `ada-procedure-start-regexp'." ;; if function, skip over 'return' and result type. (if func-found (progn - (forward-word 1) + (forward-word-strictly 1) (skip-chars-forward " \t\n") (setq functype (buffer-substring (point) (progn @@ -5327,7 +5331,7 @@ for `ada-procedure-start-regexp'." (if (looking-at "^[ \t]*task") (progn (message "Task conversion is not yet implemented") - (forward-word 2) + (forward-word-strictly 2) (if (looking-at "[ \t]*;") (forward-line) (ada-move-to-end)) diff --git a/lisp/progmodes/cc-align.el b/lisp/progmodes/cc-align.el index d59503be61..a2077be24f 100644 --- a/lisp/progmodes/cc-align.el +++ b/lisp/progmodes/cc-align.el @@ -449,7 +449,7 @@ class Foo class Foo Works with: inher-cont." (save-excursion (goto-char (c-langelem-pos langelem)) - (forward-word 1) + (forward-word-strictly 1) (if (looking-at "[ \t]*$") c-basic-offset (c-forward-syntactic-ws) diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 06e11b25d2..380ea15cc8 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -6083,7 +6083,7 @@ comment at the start of cc-engine.el for more info." (when (or (looking-at "extends") (looking-at "super")) - (forward-word) + (forward-word-strictly) (c-forward-syntactic-ws) (let ((c-promote-possible-types t) (c-record-found-types t)) diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index de546f7c1d..83eded136e 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -2304,7 +2304,7 @@ to nil." (memq this-command '(self-insert-command newline)))) head1 notlast name p really-delete over) (and (save-excursion - (forward-word -1) + (forward-word-strictly -1) (and (eq (preceding-char) ?=) (progn @@ -2327,7 +2327,7 @@ to nil." (progn (insert "\n\n=cut") (cperl-ensure-newlines 2) - (forward-word -2) + (forward-word-strictly -2) (if (and head1 (not (save-excursion @@ -2335,7 +2335,7 @@ to nil." (re-search-backward "\\(\\`\n?\\|\n\n\\)=head1\\>" nil t)))) ; Only one (progn - (forward-word 1) + (forward-word-strictly 1) (setq name (file-name-base) p (point)) (insert " NAME\n\n" name @@ -2343,10 +2343,10 @@ to nil." "=head1 DESCRIPTION") (cperl-ensure-newlines 4) (goto-char p) - (forward-word 2) + (forward-word-strictly 2) (end-of-line) (setq really-delete t)) - (forward-word 1)))) + (forward-word-strictly 1)))) (if over (progn (setq p (point)) @@ -2354,7 +2354,7 @@ to nil." "=back") (cperl-ensure-newlines 2) (goto-char p) - (forward-word 1) + (forward-word-strictly 1) (end-of-line) (setq really-delete t))) (if (and delete really-delete) @@ -2480,7 +2480,7 @@ If in POD, insert appropriate lines." (if (and over (progn (forward-paragraph -1) - (forward-word 1) + (forward-word-strictly 1) (setq pos (point)) (setq cut (buffer-substring (point) (point-at-eol))) (delete-char (- (point-at-eol) (point))) @@ -2531,7 +2531,7 @@ If in POD, insert appropriate lines." ;; and do no indentation for them. (and (eq last-command-event ?:) (save-excursion - (forward-word 1) + (forward-word-strictly 1) (skip-chars-forward " \t") (and (< (point) end) (progn (goto-char (- end 1)) @@ -4309,7 +4309,7 @@ the sections using `cperl-pod-head-face', `cperl-pod-face', ;; Now: tail: if the second part is non-matching without ///e (if (eq (char-syntax (following-char)) ?w) (progn - (forward-word 1) ; skip modifiers s///s + (forward-word-strictly 1) ; skip modifiers s///s (if tail (cperl-commentify tail (point) t)) (cperl-postpone-fontification e1 (point) 'face my-cperl-REx-modifiers-face))) @@ -5110,7 +5110,7 @@ Returns some position at the last line." (if (looking-at "[ \t]*}?[ \t]*\\<\\(\\els\\(e\\|if\\)\\|continue\\|unless\\|if\\|while\\|for\\(each\\)?\\|until\\)\\>\\(\t*\\|[ \t][ \t]+\\)[^ \t\n#]") (progn - (forward-word 1) + (forward-word-strictly 1) (delete-horizontal-space) (insert (make-string cperl-indent-region-fix-constructs ?\s)) (beginning-of-line))) @@ -5119,7 +5119,7 @@ Returns some position at the last line." (if (looking-at "[ \t]*\\= dir 0) (end-of-line)) ;Make sure we are in current block (if (setq found (idlwave-find-key block-reg dir t unit-limit)) (while (and found (looking-at block-limit)) - (if (>= dir 0) (forward-word 1)) + (if (>= dir 0) (forward-word-strictly 1)) (idlwave-block-jump-out dir t) (setq found (idlwave-find-key block-reg dir t unit-limit)))) (if (not nomark) (push-mark here)) (if (not found) (goto-char unit-limit) - (if (>= dir 0) (forward-word 1))))) + (if (>= dir 0) (forward-word-strictly 1))))) (defun idlwave-min-current-statement-indent (&optional end-reg) "The minimum indent in the current statement." @@ -6325,7 +6325,7 @@ Must accept two arguments: `apos' and `info'.") (is-self (and arrow (save-excursion (goto-char apos) - (forward-word -1) + (forward-word-strictly -1) (let ((case-fold-search t)) (looking-at "self\\>"))))) (force-query idlwave-force-class-query) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 1e5cc60ee5..15a52ba8cd 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -838,7 +838,7 @@ return the name of the function, or t if the name could not be determined. Otherwise, return nil." (cl-assert (looking-at "\\_")) (let ((name t)) - (forward-word) + (forward-word-strictly) (forward-comment most-positive-fixnum) (when (eq (char-after) ?*) (forward-char) diff --git a/lisp/progmodes/mantemp.el b/lisp/progmodes/mantemp.el index 913849df32..ea9d400dd9 100644 --- a/lisp/progmodes/mantemp.el +++ b/lisp/progmodes/mantemp.el @@ -157,8 +157,8 @@ the lines." "^template class [A-z :&*<>~=,0-9+!]*(" nil t nil) (progn (beginning-of-line) - (forward-word 1) - (delete-region (point) (progn (forward-word 1) (point))))))) + (forward-word-strictly 1) + (delete-region (point) (progn (forward-word-strictly 1) (point))))))) (defun mantemp-make-mantemps () "Gathering interface to the functions modifying the buffer." diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index 28619a5585..f309565acf 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -1088,7 +1088,7 @@ The value is (START END NAME-START NAME-END) of the function." (save-excursion (goto-char (point-min)) (when (equal (funcall smie-forward-token-function) "function") - (forward-word -1) + (forward-word-strictly -1) (let* ((start (point)) (end (progn (forward-sexp 1) (point))) (name (when (progn diff --git a/lisp/progmodes/pascal.el b/lisp/progmodes/pascal.el index b0929ebd04..76441ea03e 100644 --- a/lisp/progmodes/pascal.el +++ b/lisp/progmodes/pascal.el @@ -1023,7 +1023,7 @@ indent of the current line in parameterlist." (let ((lineup (if (or (looking-at "\\\\|\\") arg start) ":" "=")) (stpos (if start start - (forward-word 2) (backward-word 1) (point))) + (forward-word-strictly 2) (backward-word 1) (point))) (edpos (set-marker (make-marker) (if end end (max (progn (pascal-declaration-end) diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index 241521bef4..7ed87e8f03 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el @@ -301,7 +301,7 @@ ;; sub tr {...} (3 (ignore (if (save-excursion (goto-char (match-beginning 0)) - (forward-word -1) + (forward-word-strictly -1) (looking-at-p "sub[ \t\n]")) ;; This is defining a function. nil @@ -404,7 +404,8 @@ (skip-syntax-backward " ") (skip-syntax-backward "w") (member (buffer-substring - (point) (progn (forward-word 1) (point))) + (point) (progn (forward-word-strictly 1) + (point))) '("tr" "s" "y")))) (close (cdr (assq char perl-quote-like-pairs))) (st (perl-quote-syntax-table char))) @@ -993,7 +994,7 @@ Returns (parse-state) if line starts inside a string." ((memq c '(?\) ?\] ?\} ?\")) (forward-sexp -1) (forward-comment (- (point))) t) ((eq ?w (char-syntax c)) - (forward-word -1) (forward-comment (- (point))) t) + (forward-word-strictly -1) (forward-comment (- (point))) t) (t (forward-char -1) (forward-comment (- (point))) t))))) ;; note: this may be slower than the c-mode version, but I can understand it. diff --git a/lisp/progmodes/ps-mode.el b/lisp/progmodes/ps-mode.el index c9299055a4..3b0694541b 100644 --- a/lisp/progmodes/ps-mode.el +++ b/lisp/progmodes/ps-mode.el @@ -1082,7 +1082,7 @@ Use line numbers if `ps-run-error-line-numbers' is not nil" (goto-char (max 1 (1- (point))))) (when (looking-at "[0-9]") (forward-char 1) - (forward-word -1) + (forward-word-strictly -1) (when (looking-at "[0-9]+") (let (i) (setq diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index d237074197..be8f96dcfd 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -448,7 +448,7 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'." (defun ruby-smie--redundant-do-p (&optional skip) (save-excursion - (if skip (backward-word 1)) + (if skip (backward-word-strictly 1)) (member (nth 2 (smie-backward-sexp ";")) '("while" "until" "for")))) (defun ruby-smie--opening-pipe-p () @@ -517,7 +517,7 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'." (setq tok (concat "." tok))) (cond ((member tok '("unless" "if" "while" "until")) - (if (save-excursion (forward-word -1) (ruby-smie--bosp)) + (if (save-excursion (forward-word-strictly -1) (ruby-smie--bosp)) tok "iuwu-mod")) ((string-match-p "\\`|[*&]?\\'" tok) (forward-char (- 1 (length tok))) @@ -575,7 +575,7 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'." ((equal tok "do") (cond ((not (ruby-smie--redundant-do-p)) tok) - ((> (save-excursion (forward-word 1) + ((> (save-excursion (forward-word-strictly 1) (forward-comment (point-max)) (point)) (line-end-position)) (ruby-smie--backward-token)) ;Fully redundant. @@ -897,7 +897,7 @@ and `\\' when preceded by `?'." ;; us to do better. (when (not (memq (car (syntax-after (1- (point)))) '(2 3 6 10))) (or (not (memq (char-before) '(?\s ?\t))) - (ignore (forward-word -1)) + (ignore (forward-word-strictly -1)) (eq (char-before) ?_) (not (looking-at ruby-singleton-class-re)))))) @@ -1240,7 +1240,7 @@ delimiter." ((let ((s (ruby-parse-region (point) ruby-indent-point))) (and (nth 2 s) (> (nth 2 s) 0) (or (goto-char (cdr (nth 1 s))) t))) - (forward-word -1) + (forward-word-strictly -1) (setq indent (ruby-indent-size (current-column) (nth 2 state)))) (t @@ -1259,7 +1259,7 @@ delimiter." (if (null (cdr (nth 1 state))) (error "Invalid nesting")) (goto-char (cdr (nth 1 state))) - (forward-word -1) ; skip back a keyword + (forward-word-strictly -1) ; skip back a keyword (setq begin (point)) (cond ((looking-at "do\\>[^_]") ; iter block is a special case @@ -1352,7 +1352,7 @@ delimiter." (forward-char -1) (not (looking-at "{"))) (progn - (forward-word -1) + (forward-word-strictly -1) (not (looking-at "do\\>[^_]"))))) (t t)))) (not (eq ?, c)) @@ -1505,10 +1505,11 @@ With ARG, do it many times. Negative ARG means move backward." (not (eq (char-before (point)) ?.)) (not (eq (char-before (point)) ?:))) (ruby-end-of-block) - (forward-word 1)) + (forward-word-strictly 1)) ((looking-at "\\(\\$\\|@@?\\)?\\sw") (while (progn - (while (progn (forward-word 1) (looking-at "_"))) + (while (progn (forward-word-strictly 1) + (looking-at "_"))) (cond ((looking-at "::") (forward-char 2) t) ((> (skip-chars-forward ".") 0)) ((looking-at "\\?\\|!\\(=[~=>]\\|[^~=]\\)") @@ -1524,7 +1525,7 @@ With ARG, do it many times. Negative ARG means move backward." (skip-chars-forward "<")) (not expr)))) (setq i (1- i))) - ((error) (forward-word 1))) + ((error) (forward-word-strictly 1))) i)))) (defun ruby-backward-sexp (&optional arg) @@ -1560,7 +1561,7 @@ With ARG, do it many times. Negative ARG means move forward." ((looking-at "\\s(") nil) (t (forward-char 1) - (while (progn (forward-word -1) + (while (progn (forward-word-strictly -1) (pcase (char-before) (`?_ t) (`?. (forward-char -1) t) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 5f29bb64f0..2b61bc2e75 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -2197,7 +2197,7 @@ Returns the construct's token and moves point before it, if so." Point should be before the newline." (save-excursion (let ((tok (funcall smie-backward-token-function))) - (if (or (when (equal tok "not") (forward-word 1) t) + (if (or (when (equal tok "not") (forward-word-strictly 1) t) (and (zerop (length tok)) (eq (char-before) ?\)))) (not (sh-smie--rc-after-special-arg-p)) (sh-smie--newline-semi-p tok))))) diff --git a/lisp/progmodes/simula.el b/lisp/progmodes/simula.el index 0c420dfbec..d627309d6a 100644 --- a/lisp/progmodes/simula.el +++ b/lisp/progmodes/simula.el @@ -568,7 +568,7 @@ The relative indentation among the lines of the statement are preserved." (if (and (eq (char-syntax (preceding-char)) ?w) (eq (char-syntax (following-char)) ?w)) (save-excursion - (backward-word 1) + (backward-word-strictly 1) (if (looking-at "end\\>\\|else\\>\\|otherwise\\>\\|when\\>") (setq return-value nil))))) ((memq (preceding-char) '(?! ?t ?T)) @@ -654,12 +654,12 @@ If COUNT is negative, move forward up block level instead." (1+ count))))) (while (< count 0) (re-search-forward "\\\\|\\") - (backward-word 1) + (backward-word-strictly 1) (if (not (simula-context)) (setq count (if (memq (following-char) '(?e ?E)) (1+ count) (1- count)))) - (backward-word -1))) + (backward-word-strictly -1))) ;; If block level not found, jump back to origin and signal an error (error (progn (goto-char origin) @@ -689,12 +689,12 @@ If COUNT is negative, move backward down block level instead." (if (< count start-count) (signal 'error nil))) (while (> count 0) (re-search-forward "\\\\|\\") - (backward-word 1) + (backward-word-strictly 1) (if (not (simula-context)) (setq count (if (memq (following-char) '(?b ?B)) (1- count) (1+ count)))) - (backward-word -1) + (backward-word-strictly -1) ;; deeper level has to be found within starting block (if (> count start-count) (signal 'error nil)))) ;; If block level not found, jump back to origin and signal an error @@ -721,9 +721,9 @@ If COUNT is negative, move forward instead." (simula-skip-comment-backward) (if (memq (preceding-char) '(?n ?N)) (progn - (backward-word 1) + (backward-word-strictly 1) (if (not (looking-at "\\")) - (backward-word -1))) + (backward-word-strictly -1))) (if (eq (preceding-char) ?\;) (backward-char 1)) ) @@ -734,7 +734,7 @@ If COUNT is negative, move forward instead." (progn (if (eq (following-char) ?\;) (forward-char 1) - (backward-word -1)))) + (backward-word-strictly -1)))) (simula-skip-comment-forward)) (error (progn (goto-char origin) (error "Incomplete statement (too many ENDs)"))) @@ -753,13 +753,13 @@ If COUNT is negative, move backward instead." (condition-case () (progn (simula-skip-comment-forward) - (if (looking-at "\\") (forward-word 1)) + (if (looking-at "\\") (forward-word-strictly 1)) (while (and (natnump (setq count (1- count))) (setq status (simula-search-forward ";\\|\\" (point-max) 'move)))) (if (and status (/= (preceding-char) ?\;)) (progn - (backward-word 1) + (backward-word-strictly 1) (simula-skip-comment-backward)))) (error (progn (goto-char origin) (error "Incomplete statement (too few ENDs)"))) @@ -802,7 +802,7 @@ If COUNT is negative, move backward instead." ((eq context 2) ;; an END-comment must belong to an END (re-search-backward "\\") - (forward-word 1) + (forward-word-strictly 1) (throw 'simula-out nil)) ;; should be impossible to get here.. ))))) @@ -915,7 +915,7 @@ If COUNT is negative, move backward instead." ((memq (following-char) '(?E ?e)) (setq indent (cdr simula-if-indent))) (t - (forward-word 1) + (forward-word-strictly 1) (setq indent 0))) (simula-find-if)) ;; @@ -939,7 +939,7 @@ If COUNT is negative, move backward instead." (not (eq (preceding-char) ?\;)) (if (memq (preceding-char) '(?N ?n)) (save-excursion - (backward-word 1) + (backward-word-strictly 1) (not (looking-at "begin\\>"))) t)) (progn @@ -954,7 +954,7 @@ If COUNT is negative, move backward instead." ;; (not found-end) (if (eq (char-syntax (preceding-char)) ?w) (progn - (backward-word 1) + (backward-word-strictly 1) (not (looking-at "begin\\|then\\|else\\|when\\|otherwise\\|do" ))) @@ -975,14 +975,14 @@ If COUNT is negative, move backward instead." ((looking-at "begin\\>") (setq indent (+ indent simula-indent-level))) ((looking-at "end\\>") - (forward-word 1) + (forward-word-strictly 1) (simula-previous-statement 1)) ((looking-at "do\\>") (setq indent (+ indent simula-substatement-offset)) (simula-find-do-match)) ((looking-at "\\(if\\|then\\|else\\)\\>") (if (memq temp '(?I ?i)) - (forward-word 1) + (forward-word-strictly 1) (setq indent (+ indent simula-substatement-offset (if (memq temp '(?T ?t)) @@ -1030,7 +1030,7 @@ If COUNT is negative, move backward instead." (and (not (bobp)) (if (eq (char-syntax (preceding-char)) ?w) (save-excursion - (backward-word 1) + (backward-word-strictly 1) (not (looking-at "begin\\|then\\|else\\|when\\|otherwise\\|do"))) (not (memq (preceding-char) '(?: ?\;)))))) @@ -1067,7 +1067,7 @@ If COUNT is negative, move backward instead." (simula-skip-comment-backward) (if (and (eq (char-syntax (preceding-char)) ?w) (progn - (backward-word 1) + (backward-word-strictly 1) (looking-at "else\\>"))) () (throw 'simula-out t))) @@ -1189,7 +1189,7 @@ If COUNT is negative, move backward instead." (if where (if (and (eq where 2) (eq (char-syntax (preceding-char)) ?w)) (save-excursion - (backward-word 1) + (backward-word-strictly 1) (not (looking-at "end\\>")))))) (unexpand-abbrev) (cond @@ -1204,7 +1204,7 @@ If COUNT is negative, move backward instead." ;; check if the expanded word is on the beginning of the line. (if (and (eq (char-syntax (preceding-char)) ?w) (progn - (backward-word 1) + (backward-word-strictly 1) (if (looking-at "end\\>") (save-excursion (simula-backward-up-level 1) diff --git a/lisp/progmodes/vera-mode.el b/lisp/progmodes/vera-mode.el index 987022e8cb..00b287e69e 100644 --- a/lisp/progmodes/vera-mode.el +++ b/lisp/progmodes/vera-mode.el @@ -1109,7 +1109,7 @@ try to increase performance by using this macro." ((and (save-excursion (vera-backward-syntactic-ws nil t) ;; previous line ends with a block opening? - (or (/= (skip-chars-backward "{") 0) (backward-word 1)) + (or (/= (skip-chars-backward "{") 0) (backward-word-strictly 1)) (when (looking-at vera-beg-block-re) ;; go to beginning of substatement (vera-beginning-of-substatement) @@ -1162,7 +1162,7 @@ try to increase performance by using this macro." ;; is this line preceded by a substatement opening statement? ((save-excursion (vera-backward-syntactic-ws nil t) (when (= (preceding-char) ?\)) (backward-sexp)) - (backward-word 1) + (backward-word-strictly 1) (setq placeholder (point)) (looking-at vera-beg-substatement-re)) (goto-char placeholder) @@ -1225,7 +1225,7 @@ Calls `indent-region' for whole buffer." "If previous word is a block closing or `else', indent line again." (when (= (char-syntax (preceding-char)) ?w) (save-excursion - (backward-word 1) + (backward-word-strictly 1) (when (and (not (vera-in-literal)) (looking-at (concat vera-end-block-re "\\|\\"))) (indent-according-to-mode))))) diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el index 6b6cc643ff..28ae3500ca 100644 --- a/lisp/progmodes/verilog-mode.el +++ b/lisp/progmodes/verilog-mode.el @@ -3470,7 +3470,7 @@ Use filename, if current buffer being edited shorten to just buffer name." (found nil) (st (point))) (if (not (looking-at "\\<")) - (forward-word -1)) + (forward-word-strictly -1)) (cond ((verilog-skip-backward-comment-or-string)) ((looking-at "\\") @@ -3522,7 +3522,7 @@ Use filename, if current buffer being edited shorten to just buffer name." (st (point)) (nest 'yes)) (if (not (looking-at "\\<")) - (forward-word -1)) + (forward-word-strictly -1)) (cond ((verilog-skip-forward-comment-or-string) (verilog-forward-syntactic-ws)) @@ -3545,11 +3545,11 @@ Use filename, if current buffer being edited shorten to just buffer name." (and (looking-at "fork") (progn (setq here (point)) ; sometimes a fork is just a fork - (forward-word -1) + (forward-word-strictly -1) (looking-at verilog-disable-fork-re)))) (progn ; it is a disable fork; ignore it (goto-char (match-end 0)) - (forward-word 1) + (forward-word-strictly 1) (setq reg nil)) (progn ; it is a nice simple fork (goto-char here) ; return from looking for "disable fork" @@ -3599,7 +3599,7 @@ Use filename, if current buffer being edited shorten to just buffer name." ;; Search forward for matching endclocking (setq reg "\\(\\\\)\\|\\(\\\\)" ))) (if (and reg - (forward-word 1)) + (forward-word-strictly 1)) (catch 'skip (if (eq nest 'yes) (let ((depth 1) @@ -3618,7 +3618,7 @@ Use filename, if current buffer being edited shorten to just buffer name." (looking-at verilog-disable-fork-re) (and (looking-at "fork") (progn - (forward-word -1) + (forward-word-strictly -1) (looking-at verilog-disable-fork-re)))) (progn ; it is a disable fork; another false alarm (goto-char (match-end 0))) @@ -4292,7 +4292,7 @@ Uses `verilog-scan' cache." ;; stop if we see a named coverpoint (looking-at "\\w+\\W*:\\W*\\(coverpoint\\|cross\\|constraint\\)") ;; keep going if we are in the middle of a word - (not (or (looking-at "\\<") (forward-word -1))) + (not (or (looking-at "\\<") (forward-word-strictly -1))) ;; stop if we see an assertion (perhaps labeled) (and (looking-at "\\(\\w+\\W*:\\W*\\)?\\(\\<\\(assert\\|assume\\|cover\\)\\>\\s-+\\\\)\\|\\(\\\\)") @@ -4841,7 +4841,7 @@ primitive or interface named NAME." ((looking-at "\\") ;; HERE - (forward-word 1) + (forward-word-strictly 1) (verilog-forward-syntactic-ws) (setq err nil) (setq str (verilog-get-expr)) @@ -5956,7 +5956,7 @@ Set point to where line starts." (verilog-backward-up-list 1) (verilog-backward-syntactic-ws) (let ((back (point))) - (forward-word -1) + (forward-word-strictly -1) (cond ;;XX ((looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|case\\(\\|[xz]\\)\\|for\\(\\|each\\|ever\\)\\|i\\(f\\|nitial\\)\\|repeat\\|while\\)\\>") @@ -5997,11 +5997,11 @@ Set point to where line starts." (;-- any of begin|initial|while are complete statements; 'begin : foo' is also complete t - (forward-word -1) + (forward-word-strictly -1) (while (or (= (preceding-char) ?\_) (= (preceding-char) ?\@) (= (preceding-char) ?\.)) - (forward-word -1)) + (forward-word-strictly -1)) (cond ((looking-at "\\") t) @@ -6515,7 +6515,7 @@ Only look at a few lines to determine indent level." (= (following-char) ?\`)) (progn (forward-char 1) - (forward-word 1) + (forward-word-strictly 1) (skip-chars-forward " \t"))) ((= (following-char) ?\[) (progn diff --git a/lisp/progmodes/vhdl-mode.el b/lisp/progmodes/vhdl-mode.el index 664642554f..27ce9fb1b3 100644 --- a/lisp/progmodes/vhdl-mode.el +++ b/lisp/progmodes/vhdl-mode.el @@ -6582,7 +6582,7 @@ returned point is at the first character of the \"libunit\" keyword." ;; keyword, allow for the keyword and an extra character, ;; as this will be used when looking forward for the ;; "begin" keyword. - (save-excursion (forward-word 1) (1+ (point)))) + (save-excursion (forward-word-strictly 1) (1+ (point)))) foundp literal placeholder) ;; Find the "libunit" keyword. (while (and (not foundp) @@ -6633,7 +6633,7 @@ stops due to beginning or end of buffer." ;; keyword, allow for the keyword and an extra character, ;; as this will be used when looking forward for the ;; "begin" keyword. - (save-excursion (forward-word 1) (1+ (point)))) + (save-excursion (forward-word-strictly 1) (1+ (point)))) begin-string literal) (while (and (not foundp) (re-search-backward vhdl-defun-re nil 'move)) @@ -6779,7 +6779,7 @@ statement if already at the beginning of one." ;; start point was not inside leader area ;; set stop point at word after leader (setq pos (point)))) - (forward-word 1) + (forward-word-strictly 1) (vhdl-forward-syntactic-ws here) (setq pos (point))) (goto-char pos) @@ -8457,7 +8457,7 @@ buffer." (setq end (vhdl-re-search-forward "\\" proc-end t)) (when (vhdl-re-search-backward "\\('event\\|\\<\\(falling\\|rising\\)_edge\\)\\>" beg t) (goto-char end) - (backward-word 1) + (backward-word-strictly 1) (vhdl-forward-sexp) (push (cons end (point)) seq-region-list) (beginning-of-line))) @@ -8929,7 +8929,7 @@ is omitted or nil." (vhdl-insert-keyword ": BLOCK ") (goto-char start) (when (setq label (vhdl-template-field "label" nil t start (+ (point) 8))) - (forward-word 1) + (forward-word-strictly 1) (forward-char 1) (insert "(") (if (vhdl-template-field "[guard expression]" nil t) @@ -8965,7 +8965,7 @@ is omitted or nil." (if (vhdl-template-field "[quantity name]" " USE " t) (progn (vhdl-template-field "quantity name" " => ") t) (delete-region (point) - (progn (forward-word -1) (point))) + (progn (forward-word-strictly -1) (point))) nil)) (vhdl-template-field "[quantity name]" " => " t)) (vhdl-template-field "expression") @@ -8998,7 +8998,7 @@ is omitted or nil." (goto-char start) (setq label (vhdl-template-field "[label]" nil t)) (unless label (delete-char 2)) - (forward-word 1) + (forward-word-strictly 1) (forward-char 1)) (when (vhdl-template-field "expression" nil t start (point)) (vhdl-insert-keyword (concat " " (if (eq kind 'is) "IS" "USE") "\n\n")) @@ -9280,7 +9280,7 @@ a configuration declaration if not within a design unit." (interactive) (insert " ") (unexpand-abbrev) - (backward-word 1) + (backward-word-strictly 1) (vhdl-case-word 1) (forward-char 1)) @@ -9289,7 +9289,7 @@ a configuration declaration if not within a design unit." (interactive) (insert " ") (unexpand-abbrev) - (backward-word 1) + (backward-word-strictly 1) (vhdl-case-word 1) (forward-char 1) (indent-according-to-mode)) @@ -9450,7 +9450,7 @@ otherwise." (goto-char start) (setq label (vhdl-template-field "[label]" nil t)) (unless label (delete-char 2)) - (forward-word 1) + (forward-word-strictly 1) (forward-char 1)) (when (setq index (vhdl-template-field "loop variable" nil t start (point))) @@ -9591,7 +9591,7 @@ otherwise." (goto-char start) (setq label (vhdl-template-field "[label]" nil t)) (unless label (delete-char 2)) - (forward-word 1) + (forward-word-strictly 1) (forward-char 1)) (when vhdl-conditions-in-parenthesis (insert "(")) (when (vhdl-template-field "condition" nil t start (point)) @@ -9674,7 +9674,7 @@ otherwise." (goto-char start) (setq label (vhdl-template-field "[label]" nil t)) (unless label (delete-char 2)) - (forward-word 1) + (forward-word-strictly 1) (delete-char 1)) (insert "\n\n") (indent-to margin) @@ -9758,11 +9758,13 @@ otherwise." (cond ((equal definition "") (insert ";")) ((equal definition "ARRAY") - (delete-region (point) (progn (forward-word -1) (point))) + (delete-region (point) (progn (forward-word-strictly -1) + (point))) (vhdl-template-array 'nature t)) ((equal definition "RECORD") (setq mid-pos (point-marker)) - (delete-region (point) (progn (forward-word -1) (point))) + (delete-region (point) (progn (forward-word-strictly -1) + (point))) (vhdl-template-record 'nature name t)) (t (vhdl-insert-keyword " ACROSS ") @@ -9875,7 +9877,7 @@ otherwise." (goto-char start) (setq label (vhdl-template-field "[label]" nil t)) (unless label (delete-char 2)) - (forward-word 1) + (forward-word-strictly 1) (forward-char 1)) (unless (vhdl-standard-p '87) (vhdl-insert-keyword "IS")) (insert "\n") @@ -9932,7 +9934,7 @@ otherwise." (goto-char start) (setq label (vhdl-template-field "[label]" nil t)) (unless label (delete-char 2)) - (forward-word 1) + (forward-word-strictly 1) (forward-char 1)) (insert "(") (if (not seq) @@ -10128,7 +10130,7 @@ otherwise." (vhdl-insert-keyword "WITH ") (when (vhdl-template-field "selector expression" nil t start (+ (point) 7)) - (forward-word 1) + (forward-word-strictly 1) (delete-char 1) (insert "\n") (indent-to (+ margin vhdl-basic-offset)) @@ -10250,11 +10252,13 @@ otherwise." (delete-char -4) (insert ";")) ((equal definition "ARRAY") - (delete-region (point) (progn (forward-word -1) (point))) + (delete-region (point) (progn (forward-word-strictly -1) + (point))) (vhdl-template-array 'type t)) ((equal definition "RECORD") (setq mid-pos (point-marker)) - (delete-region (point) (progn (forward-word -1) (point))) + (delete-region (point) (progn (forward-word-strictly -1) + (point))) (vhdl-template-record 'type name t)) ((equal definition "ACCESS") (insert " ") @@ -10298,7 +10302,8 @@ otherwise." (if (or (save-excursion (progn (vhdl-beginning-of-block) (looking-at "\\s-*\\(\\w+\\s-*:\\s-*\\)?\\<\\(\\"))) - (save-excursion (backward-word 1) (looking-at "\\"))) + (save-excursion (backward-word-strictly 1) + (looking-at "\\"))) (vhdl-insert-keyword "VARIABLE ") (if (vhdl-standard-p '87) (error "ERROR: Not within sequential block") @@ -10356,7 +10361,7 @@ otherwise." (goto-char start) (setq label (vhdl-template-field "[label]" nil t)) (unless label (delete-char 2)) - (forward-word 1) + (forward-word-strictly 1) (forward-char 1)) (when vhdl-conditions-in-parenthesis (insert "(")) (when (vhdl-template-field "condition" nil t start (point)) @@ -11218,7 +11223,7 @@ else insert tab (used for word completion in VHDL minibuffer)." (save-match-data (save-excursion (goto-char (match-end 5)) - (forward-word 1) + (forward-word-strictly 1) (vhdl-forward-syntactic-ws) (when (looking-at "(") (forward-sexp)) @@ -11292,19 +11297,19 @@ else insert tab (used for word completion in VHDL minibuffer)." but not if inside a comment or quote." (if (or (vhdl-in-literal) (save-excursion - (forward-word -1) + (forward-word-strictly -1) (and (looking-at "\\") (not (looking-at "\\\\)?") (setq name (match-string-no-properties 1)) (message "Reading port of %s \"%s\"..." decl-type name) @@ -13211,7 +13216,7 @@ File statistics: \"%s\"\n\ ;; subprogram body (when (match-string 2) (re-search-forward "^\\s-*\\" nil t) - (backward-word 1) + (backward-word-strictly 1) (vhdl-forward-sexp))) ;; block (recursive) ((looking-at "^\\s-*\\w+\\s-*:\\s-*block\\>") @@ -13224,7 +13229,7 @@ File statistics: \"%s\"\n\ (re-search-forward "^\\s-*end\\s-+process\\>" nil t)) ;; configuration declaration ((looking-at "^\\s-*configuration\\>") - (forward-word 4) + (forward-word-strictly 4) (vhdl-forward-sexp)) (t (goto-char pos)))))) diff --git a/lisp/simple.el b/lisp/simple.el index e5fb5f031d..1701eb0e0f 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1170,7 +1170,7 @@ END, without printing any message." (save-restriction (narrow-to-region start end) (goto-char (point-min)) - (while (forward-word 1) + (while (forward-word-strictly 1) (setq words (1+ words))))) words)) ((use-region-p) diff --git a/lisp/skeleton.el b/lisp/skeleton.el index b9c1bb506d..0e81e2d74c 100644 --- a/lisp/skeleton.el +++ b/lisp/skeleton.el @@ -244,7 +244,8 @@ When done with skeleton, but before going back to `_'-point call (setq skeleton-regions (if (> skeleton-regions 0) (list (copy-marker (point) t) - (save-excursion (forward-word skeleton-regions) + (save-excursion (forward-word-strictly + skeleton-regions) (point-marker))) (setq skeleton-regions (- skeleton-regions)) ;; copy skeleton-regions - 1 elements from `mark-ring' diff --git a/lisp/subr.el b/lisp/subr.el index fb1e0291a7..cad6319f3b 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -4267,6 +4267,39 @@ If SYNTAX is nil, return nil." ;; Utility motion commands +(defvar word-move-empty-char-table nil + "Used in `forward-word-strictly' and `backward-word-strictly' +to countermand the effect of `find-word-boundary-function-table'.") + +(defun forward-word-strictly (&optional arg) + "Move point forward ARG words (backward if ARG is negative). +If ARG is omitted or nil, move point forward one word. +Normally returns t. +If an edge of the buffer or a field boundary is reached, point is left there +and the function returns nil. Field boundaries are not noticed if +`inhibit-field-text-motion' is non-nil. + +This function is like `forward-word', but it is not affected +by `find-word-boundary-function-table'. It is also not interactive." + (let ((find-word-boundary-function-table + (if (char-table-p word-move-empty-char-table) + word-move-empty-char-table + (setq word-move-empty-char-table (make-char-table nil))))) + (forward-word (or arg 1)))) + +(defun backward-word-strictly (&optional arg) + "Move backward until encountering the beginning of a word. +With argument ARG, do this that many times. +If ARG is omitted or nil, move point backward one word. + +This function is like `forward-word', but it is not affected +by `find-word-boundary-function-table'. It is also not interactive." + (let ((find-word-boundary-function-table + (if (char-table-p word-move-empty-char-table) + word-move-empty-char-table + (setq word-move-empty-char-table (make-char-table nil))))) + (forward-word (- (or arg 1))))) + ;; Whitespace (defun forward-whitespace (arg) diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 5db0d987a0..042b7d40ed 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -368,7 +368,7 @@ property of the major mode name.") (defun texinfo-mode-flyspell-verify () "Function used for `flyspell-generic-check-word-predicate' in Texinfo mode." (save-excursion - (forward-word -1) + (forward-word-strictly -1) (not (looking-at "@")))) ;;*--- tex mode --------------------------------------------------------*/ diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index 5b1bd6a05b..973b2d373d 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -735,7 +735,8 @@ automatically inserts its partner." (let ((arg-end (match-end 0))) (if (null type) ;\end (progn (goto-char arg-end) - (latex-forward-sexp -1) (forward-word 1)) + (latex-forward-sexp -1) + (forward-word-strictly 1)) (goto-char cmd-start) (latex-forward-sexp 1) (let (forward-sexp-function) (backward-sexp))) diff --git a/lisp/textmodes/texinfmt.el b/lisp/textmodes/texinfmt.el index 19a21237d2..55be7fe9df 100644 --- a/lisp/textmodes/texinfmt.el +++ b/lisp/textmodes/texinfmt.el @@ -891,7 +891,7 @@ commands." ;; @ is followed by a command-word; find the end of the word. (setq texinfo-command-start (1- (point))) (if (= (char-syntax (following-char)) ?w) - (forward-word 1) + (forward-word-strictly 1) (forward-char 1)) (setq texinfo-command-end (point)) ;; Detect the case of two @-commands in a row; @@ -1190,7 +1190,7 @@ Leave point after argument." (forward-paragraph) (let ((end (point))) (if (save-excursion - (backward-word 1) + (backward-word-strictly 1) (search-forward "@refill" end t)) (setq anchor-string "@anchor-yes-refill") (setq anchor-string "@anchor-no-refill"))) @@ -2003,7 +2003,7 @@ commands that are defined in texinfo.tex for printed output. (error "In @multitable, @columnfractions misspelled")) ;; Case 1: @columnfractions .25 .3 .45 ((looking-at "@columnfractions") - (forward-word 1) + (forward-word-strictly 1) (while (not (eolp)) (push (truncate (1- @@ -2118,7 +2118,7 @@ This command is executed when texinfmt sees @item inside @multitable." ;; Delete the @tab command, including the @-sign (delete-region (point) - (progn (forward-word -1) (1- (point))))) + (progn (forward-word-strictly -1) (1- (point))))) (point))) ;; Set fill-column *wider* than needed to produce inter-column space (setq fill-column (+ 1 diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el index 12a991163b..ed6022f9fb 100644 --- a/lisp/textmodes/texinfo.el +++ b/lisp/textmodes/texinfo.el @@ -393,7 +393,7 @@ Subexpression 1 is what goes into the corresponding `@end' statement.") (unless (get-char-property start 'text-clones) (if endp (texinfo-last-unended-begin) - (forward-word 1) + (forward-word-strictly 1) (texinfo-next-unmatched-end)) (skip-syntax-forward "^w") (when (looking-at @@ -738,7 +738,7 @@ With prefix argument or inside @code or @example, inserts a plain \"." "Insert the matching `@end' for the last Texinfo command that needs one." (ignore-errors (save-excursion - (backward-word 1) + (backward-word-strictly 1) (texinfo-last-unended-begin) (or (match-string 1) '-))) \n "@end " str \n \n) diff --git a/lisp/textmodes/texnfo-upd.el b/lisp/textmodes/texnfo-upd.el index 8f40132344..b01c678ffe 100644 --- a/lisp/textmodes/texnfo-upd.el +++ b/lisp/textmodes/texnfo-upd.el @@ -519,7 +519,7 @@ line. If there is no node name, returns an empty string." (save-excursion (buffer-substring - (progn (forward-word 1) ; skip over node command + (progn (forward-word-strictly 1) ; skip over node command (skip-chars-forward " \t") ; and over spaces (point)) (if (search-forward "," (line-end-position) t) ; bound search @@ -542,7 +542,7 @@ must have been done by `texinfo-menu-locate-entry-p'." (goto-char (match-beginning 7)) ; match section name (buffer-substring - (progn (forward-word 1) ; skip over section type + (progn (forward-word-strictly 1) ; skip over section type (skip-chars-forward " \t") ; and over spaces (point)) (progn (end-of-line) (point)))) @@ -794,7 +794,7 @@ complements the node name rather than repeats it as a title does." (setq title (buffer-substring ;; skip over section type - (progn (forward-word 1) + (progn (forward-word-strictly 1) ;; and over spaces (skip-chars-forward " \t") (point)) @@ -1104,7 +1104,7 @@ point." t) (progn (beginning-of-line) - (forward-word 1) ; skip over section type + (forward-word-strictly 1) ; skip over section type (skip-chars-forward " \t") ; and over spaces (buffer-substring (point) @@ -1167,7 +1167,7 @@ error if the node is not the top node and a section is not found." (setq sec-name (buffer-substring-no-properties (progn (beginning-of-line) ; copy its name (1+ (point))) - (progn (forward-word 1) + (progn (forward-word-strictly 1) (point)))))) (cond ((or sec-pos top-pos) @@ -1374,7 +1374,7 @@ Point must be at beginning of node line. Does not move point." (save-excursion (let ((initial (texinfo-copy-next-section-title))) ;; This is not clean. Use `interactive' to read the arg. - (forward-word 1) ; skip over node command + (forward-word-strictly 1) ; skip over node command (skip-chars-forward " \t") ; and over spaces (if (not (looking-at "[^,\t\n ]+")) ; regexp based on what Info looks for ; alternatively, use "[a-zA-Z]+" @@ -1700,7 +1700,7 @@ node names in pre-existing `@node' lines that lack names." (if title-p (progn (beginning-of-line) - (forward-word 1) + (forward-word-strictly 1) (skip-chars-forward " \t") (setq title (buffer-substring (point) @@ -1713,7 +1713,7 @@ node names in pre-existing `@node' lines that lack names." (line-beginning-position -1)) t) ;; @node is present, and point at beginning of that line - (forward-word 1) ; Leave point just after @node. + (forward-word-strictly 1) ; Leave point just after @node. ;; Else @node missing; insert one. (beginning-of-line) ; Beginning of `@section' line. (insert "@node\n") @@ -1728,7 +1728,7 @@ node names in pre-existing `@node' lines that lack names." (if (not (looking-at "[^,\t\n ]+")) (progn (beginning-of-line) - (forward-word 1) + (forward-word-strictly 1) (insert " " title) (message "Inserted title %s ... " title))))) ;; Go forward beyond current section title. @@ -1813,7 +1813,7 @@ same place. If there is no title, returns an empty string." ;; copy title (let ((title (buffer-substring - (progn (forward-word 1) ; skip over section type + (progn (forward-word-strictly 1) ; skip over section type (skip-chars-forward " \t") ; and over spaces (point)) (progn (end-of-line) (point))))) diff --git a/lisp/wdired.el b/lisp/wdired.el index 9109303212..2e68bec6fd 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -685,7 +685,7 @@ If OLD, return the old target. If MOVE, move point before it." (funcall command 1) (setq arg (1- arg))) (error - (if (forward-word) + (if (forward-word-strictly) ;; Skip any non-word characters to avoid triggering a read-only ;; error which would cause skipping the next word characters too. (skip-syntax-forward "^w") diff --git a/src/syntax.c b/src/syntax.c index ffe0ea5e0d..fc8c666cec 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -3771,11 +3771,11 @@ Each function is called with two arguments; POS and LIMIT. POS and LIMIT are character positions in the current buffer. If POS is less than LIMIT, POS is at the first character of a word, -and the return value of a function is a position after the last -character of that word. +and the return value of a function should be a position after the +last character of that word. If POS is not less than LIMIT, POS is at the last character of a word, -and the return value of a function is a position at the first +and the return value of a function should be a position at the first character of that word. In both cases, LIMIT bounds the search. */);