* 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)
<find-word-boundary-function-table>: 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.]
@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.
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
@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
@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
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
;; 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)
(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.
;; 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)
;; 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.
;; 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.
(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)
;; 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.
;; 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)))))
(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)))))
;; 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)
;; 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)))
(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
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))))))
(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
(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)
(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) ? )))))))))
)
(t
(setq atom-beg (point))
- (forward-word 1)
+ (forward-word-strictly 1)
(setq atom-end (point))
(goto-char atom-beg)
(save-restriction
(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)))
(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))
(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))
;; 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 "<URL:"))
- (backward-word 1)
+ (backward-word-strictly 1)
(let ((word (funcall quickurl-grab-lookup-function)))
(when word
(quickurl-make-url
(beginning-of-line)
(looking-at ada-compile-goto-error-file-linenr-re))
(save-excursion
- (if (looking-at "\\([0-9]+\\)") (backward-word 1))
+ (if (looking-at "\\([0-9]+\\)") (backward-word-strictly 1))
(looking-at "line \\([0-9]+\\)"))))
)
(let ((line (if (match-beginning 2) (match-string 2) (match-string 1)))
(save-excursion
(let ((aa-end (point)))
(ada-adjust-case-region
- (progn (goto-char (symbol-value 'beg)) (forward-word -1) (point))
+ (progn (goto-char (symbol-value 'beg)) (forward-word-strictly -1)
+ (point))
(goto-char aa-end)))))
(defun ada-region-selected ()
(save-excursion
(skip-syntax-backward "w")
(setq word (buffer-substring-no-properties
- (point) (save-excursion (forward-word 1) (point)))))))
+ (point) (save-excursion (forward-word-strictly 1)
+ (point)))))))
;; Reread the exceptions file, in case it was modified by some other,
(ada-case-read-exceptions-from-file file-name)
(skip-syntax-backward "w")
(setq word (buffer-substring-no-properties
(point)
- (save-excursion (forward-word 1) (point))))))
+ (save-excursion (forward-word-strictly 1)
+ (point))))))
(modify-syntax-entry ?_ (make-string 1 underscore-syntax)
(syntax-table))))))
;; do not add it again. This way, the user can easily decide which
;; priority should be applied to each casing exception
(let ((word (buffer-substring-no-properties
- (point) (save-excursion (forward-word 1) (point)))))
+ (point) (save-excursion (forward-word-strictly 1)
+ (point)))))
;; Handling a substring ?
(if (char-equal (string-to-char word) ?*)
(defun ada-after-keyword-p ()
"Return t if cursor is after a keyword that is not an attribute."
(save-excursion
- (forward-word -1)
+ (forward-word-strictly -1)
(and (not (and (char-before)
(or (= (char-before) ?_)
(= (char-before) ?'))));; unless we have a _ or '
(goto-char apos)
(ada-goto-next-non-ws)
(while (looking-at "\\<\\(in\\|out\\|access\\)\\>")
- (forward-word 1)
+ (forward-word-strictly 1)
(ada-goto-next-non-ws))
;; read type of parameter
(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
(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)))))))
;; avoid "with procedure"... in generic parts
(save-excursion
- (forward-word -1)
+ (forward-word-strictly -1)
(setq found (not (looking-at "with"))))))
(cond
;; yes, look what's following 'end'
(progn
- (forward-word 1)
+ (forward-word-strictly 1)
(ada-goto-next-non-ws)
(cond
;;
(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\\)\\>")
(looking-at "\\<then\\>"))
(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))))
(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
(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 "\\<use\\>")
;;
"end" nil orgpoint nil 'word-search-forward))
(ada-goto-next-non-ws)
(looking-at "\\<record\\>")
- (forward-word 1)
+ (forward-word-strictly 1)
(ada-goto-next-non-ws)
(= (char-after) ?\;)))
(goto-char (car match-dat))
(save-excursion
(ada-goto-previous-word)
(looking-at "\\<\\(end\\|or\\|and\\)\\>[ \t]*[^;]")))
- (forward-word -1))
+ (forward-word-strictly -1))
((looking-at "is")
(setq found
((looking-at "private")
(save-excursion
- (backward-word 1)
+ (backward-word-strictly 1)
(setq found (not (looking-at "is")))))
(t
(if (looking-at "\\<declare\\>")
(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)))
;;
;;
((looking-at "if")
(save-excursion
- (forward-word -1)
+ (forward-word-strictly -1)
(unless (looking-at "\\<end[ \t\n]*if\\>")
(progn
(setq nest-count (1- nest-count))
;;
((looking-at "when")
(save-excursion
- (forward-word -1)
+ (forward-word-strictly -1)
(unless (looking-at "\\<exit[ \t\n]*when\\>")
(progn
(if stop-at-when
(unless (and (looking-at "\\<record\\>")
(save-excursion
- (forward-word -1)
+ (forward-word-strictly -1)
(looking-at "\\<null\\>")))
(progn
;; calculate nest-depth
(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 ....
;; 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 "\\<body\\>"))
((looking-at "\\<type\\>")
;; 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
(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))
;;
;; 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:
((and (looking-at "\\<procedure\\|function\\>"))
(if first
- (forward-word 1)
+ (forward-word-strictly 1)
(setq pos (point))
(ada-search-ignore-string-comment "is\\|;")
(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
(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))
(save-excursion
(and (looking-at "\\<or\\>")
(progn
- (forward-word 1)
+ (forward-word-strictly 1)
(ada-goto-stmt-start)
(looking-at "\\<or\\>")))))
(progn (forward-comment -1000)
(and (not (bobp))
(or (= (char-before) ?\;)
- (and (forward-word -3)
+ (and (forward-word-strictly -3)
(looking-at "\\<package\\>"))))))))
(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:
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))
(ada-in-string-or-comment-p)
(and (progn
(or (looking-at "[ \t]*\\<end\\>")
- (backward-word 1))
+ (backward-word-strictly 1))
(or (looking-at "[ \t]*\\<end\\>")
- (backward-word 1))
+ (backward-word-strictly 1))
(or (looking-at "[ \t]*\\<end\\>")
(error "Not on end ...;")))
(ada-goto-matching-start 1)
((save-excursion
(and (ada-goto-stmt-start)
(looking-at "\\<task\\>" )
- (forward-word 1)
+ (forward-word-strictly 1)
(ada-goto-next-non-ws)
(looking-at "\\<body\\>")))
(ada-search-ignore-string-comment "begin" nil nil nil
(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_'")))
((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
;; 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
(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))
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)
(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))
(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
(progn
(insert "\n\n=cut")
(cperl-ensure-newlines 2)
- (forward-word -2)
+ (forward-word-strictly -2)
(if (and head1
(not
(save-excursion
(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
"=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))
"=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)
(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)))
;; 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))
;; 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)))
(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)))
(if (looking-at
"[ \t]*\\<for\\(each\\)?[ \t]+\\(my\\|local\\|our\\)\\(\t*\\|[ \t][ \t]+\\)[^ \t\n]")
(progn
- (forward-word 2)
+ (forward-word-strictly 2)
(delete-horizontal-space)
(insert (make-string cperl-indent-region-fix-constructs ?\s))
(beginning-of-line)))
(insert B " ")
(and B-comment (insert B-comment " "))
(just-one-space)
- (forward-word 1)
+ (forward-word-strictly 1)
(setq pre-A (point))
(insert " " A ";")
(delete-horizontal-space)
(setq ref-point (point)
;; FIXME this does not work for constructs with
;; embedded space, eg "sync all".
- back-point (save-excursion (backward-word 1) (point))
+ back-point (save-excursion (backward-word-strictly 1)
+ (point))
saveword (buffer-substring back-point ref-point))
(funcall change-word -1)
(or (string= saveword (buffer-substring back-point ref-point))
(let* ((default (save-excursion
(beginning-of-line)
(cond ((looking-at hif-ifx-else-endif-regexp)
- (forward-word 2)
+ (forward-word-strictly 2)
(current-word 'strict))
(t
nil))))
(ch-syntax (char-syntax ch)))
(if (eq ch-syntax ?w)
(assoc (buffer-substring
- (progn (forward-word -1) (point))
- (progn (forward-word 1) (point)))
+ (progn (forward-word-strictly -1) (point))
+ (progn (forward-word-strictly 1) (point)))
icon-resword-alist)
(not (memq ch '(0 ?\; ?\} ?\{ ?\) ?\] ?\" ?\' ?\# ?\, ?\. ?\n))))))
((and (eq (char-syntax (following-char)) ?w)
(cdr
(assoc (buffer-substring (point)
- (save-excursion (forward-word 1) (point)))
+ (save-excursion (forward-word-strictly 1)
+ (point)))
icon-resword-alist))) 0)
(t (end-of-line 0) (icon-backward-to-start-of-continued-exp lim))))
(interactive)
(if (not (bobp)) (forward-char -1))
(re-search-forward "\\(\\s \\|^\\)end\\(\\s \\|$\\)" (point-max) 'move)
- (forward-word -1)
+ (forward-word-strictly -1)
(forward-line 1))
\f
(defun indent-icon-exp ()
(if (not (idlwave-quoted))
(if
(save-excursion
- (backward-word 1)
+ (backward-word-strictly 1)
(backward-char 1)
(looking-at "[ \t\n\f]"))
(idlwave-show-begin))))
"Go to the beginning of the current block."
(interactive)
(idlwave-block-jump-out -1 'nomark)
- (forward-word 1))
+ (forward-word-strictly 1))
(defun idlwave-end-of-block ()
"Go to the beginning of the current block."
(interactive)
(idlwave-block-jump-out 1 'nomark)
- (backward-word 1))
+ (backward-word-strictly 1))
(defun idlwave-forward-block (&optional arg)
"Move across next nested block."
(if (>= 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."
(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)
determined. Otherwise, return nil."
(cl-assert (looking-at "\\_<function\\_>"))
(let ((name t))
- (forward-word)
+ (forward-word-strictly)
(forward-comment most-positive-fixnum)
(when (eq (char-after) ?*)
(forward-char)
"^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."
(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
(let ((lineup (if (or (looking-at "\\<var\\>\\|\\<record\\>") 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)
;; 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
(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)))
((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)))))
\f
;; note: this may be slower than the c-mode version, but I can understand it.
(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
(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 ()
(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)))
((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.
;; 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))))))
((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
(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
(forward-char -1)
(not (looking-at "{")))
(progn
- (forward-word -1)
+ (forward-word-strictly -1)
(not (looking-at "do\\>[^_]")))))
(t t))))
(not (eq ?, c))
(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 "\\?\\|!\\(=[~=>]\\|[^~=]\\)")
(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)
((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)
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)))))
(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))
(1+ count)))))
(while (< count 0)
(re-search-forward "\\<begin\\>\\|\\<end\\>")
- (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)
(if (< count start-count) (signal 'error nil)))
(while (> count 0)
(re-search-forward "\\<begin\\>\\|\\<end\\>")
- (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
(simula-skip-comment-backward)
(if (memq (preceding-char) '(?n ?N))
(progn
- (backward-word 1)
+ (backward-word-strictly 1)
(if (not (looking-at "\\<begin\\>"))
- (backward-word -1)))
+ (backward-word-strictly -1)))
(if (eq (preceding-char) ?\;)
(backward-char 1))
)
(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)")))
(condition-case ()
(progn
(simula-skip-comment-forward)
- (if (looking-at "\\<end\\>") (forward-word 1))
+ (if (looking-at "\\<end\\>") (forward-word-strictly 1))
(while (and (natnump (setq count (1- count)))
(setq status (simula-search-forward
";\\|\\<end\\>" (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)")))
((eq context 2)
;; an END-comment must belong to an END
(re-search-backward "\\<end\\>")
- (forward-word 1)
+ (forward-word-strictly 1)
(throw 'simula-out nil))
;; should be impossible to get here..
)))))
((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))
;;
(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
;; (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"
)))
((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))
(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) '(?: ?\;))))))
(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)))
(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
;; 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)
((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)
;; 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)
"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 "\\|\\<else\\>")))
(indent-according-to-mode)))))
(found nil)
(st (point)))
(if (not (looking-at "\\<"))
- (forward-word -1))
+ (forward-word-strictly -1))
(cond
((verilog-skip-backward-comment-or-string))
((looking-at "\\<else\\>")
(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))
(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"
;; Search forward for matching endclocking
(setq reg "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" )))
(if (and reg
- (forward-word 1))
+ (forward-word-strictly 1))
(catch 'skip
(if (eq nest 'yes)
(let ((depth 1)
(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)))
;; 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-+\\<property\\>\\)\\|\\(\\<assert\\>\\)")
((looking-at "\\<end\\>")
;; HERE
- (forward-word 1)
+ (forward-word-strictly 1)
(verilog-forward-syntactic-ws)
(setq err nil)
(setq str (verilog-get-expr))
(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\\)\\>")
(;-- 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 "\\<else\\>")
t)
(= (following-char) ?\`))
(progn
(forward-char 1)
- (forward-word 1)
+ (forward-word-strictly 1)
(skip-chars-forward " \t")))
((= (following-char) ?\[)
(progn
;; 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)
;; 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))
;; 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)
(setq end (vhdl-re-search-forward "\\<then\\>" 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)))
(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)
(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")
(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"))
(interactive)
(insert " ")
(unexpand-abbrev)
- (backward-word 1)
+ (backward-word-strictly 1)
(vhdl-case-word 1)
(forward-char 1))
(interactive)
(insert " ")
(unexpand-abbrev)
- (backward-word 1)
+ (backward-word-strictly 1)
(vhdl-case-word 1)
(forward-char 1)
(indent-according-to-mode))
(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)))
(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))
(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)
(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 ")
(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")
(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)
(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))
(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 " ")
(if (or (save-excursion
(progn (vhdl-beginning-of-block)
(looking-at "\\s-*\\(\\w+\\s-*:\\s-*\\)?\\<\\(\\<function\\|procedure\\|process\\|procedural\\)\\>")))
- (save-excursion (backward-word 1) (looking-at "\\<shared\\>")))
+ (save-excursion (backward-word-strictly 1)
+ (looking-at "\\<shared\\>")))
(vhdl-insert-keyword "VARIABLE ")
(if (vhdl-standard-p '87)
(error "ERROR: Not within sequential block")
(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))
(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))
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 "\\<end\\>") (not (looking-at "\\<end;")))))
(progn
(insert " ")
(unexpand-abbrev)
- (backward-word 1)
+ (backward-word-strictly 1)
(vhdl-case-word 1)
(delete-char 1))
(if (not vhdl-electric-mode)
(progn
(insert " ")
(unexpand-abbrev)
- (backward-word 1)
+ (backward-word-strictly 1)
(vhdl-case-word 1)
(delete-char 1))
(let ((invoke-char vhdl-last-input-event)
(equal "END" (upcase (match-string 1))))
(throw 'parse "ERROR: Not within an entity or component declaration"))
(setq decl-type (downcase (match-string-no-properties 1)))
- (forward-word 1)
+ (forward-word-strictly 1)
(vhdl-parse-string "\\s-+\\(\\w+\\)\\(\\s-+is\\>\\)?")
(setq name (match-string-no-properties 1))
(message "Reading port of %s \"%s\"..." decl-type name)
;; subprogram body
(when (match-string 2)
(re-search-forward "^\\s-*\\<begin\\>" nil t)
- (backward-word 1)
+ (backward-word-strictly 1)
(vhdl-forward-sexp)))
;; block (recursive)
((looking-at "^\\s-*\\w+\\s-*:\\s-*block\\>")
(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))))))
(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)
(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'
\f
;; 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)
(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 --------------------------------------------------------*/
(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)))
;; @ 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;
(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")))
(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-
;; 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
(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
"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)
(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
(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))))
(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))
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)
(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)
(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]+"
(if title-p
(progn
(beginning-of-line)
- (forward-word 1)
+ (forward-word-strictly 1)
(skip-chars-forward " \t")
(setq title (buffer-substring
(point)
(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")
(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.
;; 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)))))
(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")
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. */);