aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Zlatanov2013-03-29 21:32:12 -0400
committerTed Zlatanov2013-03-29 21:32:12 -0400
commit0b9381901012fc5626414cb083c5d97ccbe037eb (patch)
tree5bef8448e6974aad1503c240efaaa930706a0cb4
parent781f4782a7b52a803f01b1c6941984cde9369603 (diff)
downloademacs-0b9381901012fc5626414cb083c5d97ccbe037eb.tar.gz
emacs-0b9381901012fc5626414cb083c5d97ccbe037eb.zip
Move forward-whitespace, forward-symbol, forward-same-syntax commands to subr.el. Use forward-symbol in supermode.el again.
* subr.el (forward-whitespace, forward-symbol) (forward-same-syntax): Move from thingatpt.el. * progmodes/subword.el: Back to using `forward-symbol'.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/progmodes/subword.el4
-rw-r--r--lisp/subr.el52
-rw-r--r--lisp/thingatpt.el49
4 files changed, 61 insertions, 51 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6bb92573d01..737a91e2e4a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12013-03-30 Teodor Zlatanov <tzz@lifelogs.com>
2
3 * progmodes/subword.el: Back to using `forward-symbol'.
4
5 * subr.el (forward-whitespace, forward-symbol)
6 (forward-same-syntax): Move from thingatpt.el.
7
12013-03-29 Leo Liu <sdl.web@gmail.com> 82013-03-29 Leo Liu <sdl.web@gmail.com>
2 9
3 * kmacro.el (kmacro-to-register): New command. 10 * kmacro.el (kmacro-to-register): New command.
diff --git a/lisp/progmodes/subword.el b/lisp/progmodes/subword.el
index 91c3a88680a..6cb4713885e 100644
--- a/lisp/progmodes/subword.el
+++ b/lisp/progmodes/subword.el
@@ -309,7 +309,7 @@ edit them as words.
309;; 309;;
310(defun subword-forward-internal () 310(defun subword-forward-internal ()
311 (if superword-mode 311 (if superword-mode
312 (forward-sexp 1) 312 (forward-symbol 1)
313 (if (and 313 (if (and
314 (save-excursion 314 (save-excursion
315 (let ((case-fold-search nil)) 315 (let ((case-fold-search nil))
@@ -325,7 +325,7 @@ edit them as words.
325 325
326(defun subword-backward-internal () 326(defun subword-backward-internal ()
327 (if superword-mode 327 (if superword-mode
328 (forward-sexp -1) 328 (forward-symbol -1)
329 (if (save-excursion 329 (if (save-excursion
330 (let ((case-fold-search nil)) 330 (let ((case-fold-search nil))
331 (re-search-backward subword-backward-regexp nil t))) 331 (re-search-backward subword-backward-regexp nil t)))
diff --git a/lisp/subr.el b/lisp/subr.el
index 4eb46ec2b01..0fed34cfe1e 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3839,6 +3839,58 @@ node `(elisp)Syntax Table Internals' for a list of codes.
3839If SYNTAX is nil, return nil." 3839If SYNTAX is nil, return nil."
3840 (and syntax (logand (car syntax) 65535))) 3840 (and syntax (logand (car syntax) 65535)))
3841 3841
3842;; Utility motion commands
3843
3844;; Whitespace
3845
3846(defun forward-whitespace (arg)
3847 "Move point to the end of the next sequence of whitespace chars.
3848Each such sequence may be a single newline, or a sequence of
3849consecutive space and/or tab characters.
3850With prefix argument ARG, do it ARG times if positive, or move
3851backwards ARG times if negative."
3852 (interactive "^p")
3853 (if (natnump arg)
3854 (re-search-forward "[ \t]+\\|\n" nil 'move arg)
3855 (while (< arg 0)
3856 (if (re-search-backward "[ \t]+\\|\n" nil 'move)
3857 (or (eq (char-after (match-beginning 0)) ?\n)
3858 (skip-chars-backward " \t")))
3859 (setq arg (1+ arg)))))
3860
3861;; Symbols
3862
3863(defun forward-symbol (arg)
3864 "Move point to the next position that is the end of a symbol.
3865A symbol is any sequence of characters that are in either the
3866word constituent or symbol constituent syntax class.
3867With prefix argument ARG, do it ARG times if positive, or move
3868backwards ARG times if negative."
3869 (interactive "^p")
3870 (if (natnump arg)
3871 (re-search-forward "\\(\\sw\\|\\s_\\)+" nil 'move arg)
3872 (while (< arg 0)
3873 (if (re-search-backward "\\(\\sw\\|\\s_\\)+" nil 'move)
3874 (skip-syntax-backward "w_"))
3875 (setq arg (1+ arg)))))
3876
3877;; Syntax blocks
3878
3879(defun forward-same-syntax (&optional arg)
3880 "Move point past all characters with the same syntax class.
3881With prefix argument ARG, do it ARG times if positive, or move
3882backwards ARG times if negative."
3883 (interactive "^p")
3884 (or arg (setq arg 1))
3885 (while (< arg 0)
3886 (skip-syntax-backward
3887 (char-to-string (char-syntax (char-before))))
3888 (setq arg (1+ arg)))
3889 (while (> arg 0)
3890 (skip-syntax-forward (char-to-string (char-syntax (char-after))))
3891 (setq arg (1- arg))))
3892
3893
3842;;;; Text clones 3894;;;; Text clones
3843 3895
3844(defun text-clone-maintain (ol1 after beg end &optional _len) 3896(defun text-clone-maintain (ol1 after beg end &optional _len)
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index 259cd772b12..f71a0d4647c 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -529,60 +529,11 @@ with angle brackets.")
529 (buffer-substring-no-properties 529 (buffer-substring-no-properties
530 (car boundary-pair) (cdr boundary-pair)))))) 530 (car boundary-pair) (cdr boundary-pair))))))
531 531
532;; Whitespace
533
534(defun forward-whitespace (arg)
535 "Move point to the end of the next sequence of whitespace chars.
536Each such sequence may be a single newline, or a sequence of
537consecutive space and/or tab characters.
538With prefix argument ARG, do it ARG times if positive, or move
539backwards ARG times if negative."
540 (interactive "p")
541 (if (natnump arg)
542 (re-search-forward "[ \t]+\\|\n" nil 'move arg)
543 (while (< arg 0)
544 (if (re-search-backward "[ \t]+\\|\n" nil 'move)
545 (or (eq (char-after (match-beginning 0)) ?\n)
546 (skip-chars-backward " \t")))
547 (setq arg (1+ arg)))))
548
549;; Buffer 532;; Buffer
550 533
551(put 'buffer 'end-op (lambda () (goto-char (point-max)))) 534(put 'buffer 'end-op (lambda () (goto-char (point-max))))
552(put 'buffer 'beginning-op (lambda () (goto-char (point-min)))) 535(put 'buffer 'beginning-op (lambda () (goto-char (point-min))))
553 536
554;; Symbols
555
556(defun forward-symbol (arg)
557 "Move point to the next position that is the end of a symbol.
558A symbol is any sequence of characters that are in either the
559word constituent or symbol constituent syntax class.
560With prefix argument ARG, do it ARG times if positive, or move
561backwards ARG times if negative."
562 (interactive "p")
563 (if (natnump arg)
564 (re-search-forward "\\(\\sw\\|\\s_\\)+" nil 'move arg)
565 (while (< arg 0)
566 (if (re-search-backward "\\(\\sw\\|\\s_\\)+" nil 'move)
567 (skip-syntax-backward "w_"))
568 (setq arg (1+ arg)))))
569
570;; Syntax blocks
571
572(defun forward-same-syntax (&optional arg)
573 "Move point past all characters with the same syntax class.
574With prefix argument ARG, do it ARG times if positive, or move
575backwards ARG times if negative."
576 (interactive "p")
577 (or arg (setq arg 1))
578 (while (< arg 0)
579 (skip-syntax-backward
580 (char-to-string (char-syntax (char-before))))
581 (setq arg (1+ arg)))
582 (while (> arg 0)
583 (skip-syntax-forward (char-to-string (char-syntax (char-after))))
584 (setq arg (1- arg))))
585
586;; Aliases 537;; Aliases
587 538
588(defun word-at-point () 539(defun word-at-point ()