diff options
| author | Joakim Verona | 2013-04-02 08:27:06 +0200 |
|---|---|---|
| committer | Joakim Verona | 2013-04-02 08:27:06 +0200 |
| commit | 39667649e3bcf9b9de7b70ee7dd2df7bfb9ac972 (patch) | |
| tree | 3a4e52c3ada312618e94abd078e384e3a6223708 /lisp | |
| parent | 86dc02fe08b1a2d26d380ba67d6a165ead70bc79 (diff) | |
| parent | 5584cae0be16d1188dbe4943e71b4954a9a028d0 (diff) | |
| download | emacs-39667649e3bcf9b9de7b70ee7dd2df7bfb9ac972.tar.gz emacs-39667649e3bcf9b9de7b70ee7dd2df7bfb9ac972.zip | |
upstream
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 22 | ||||
| -rw-r--r-- | lisp/case-table.el | 40 | ||||
| -rw-r--r-- | lisp/facemenu.el | 15 | ||||
| -rw-r--r-- | lisp/gnus/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/gnus/gnus-msg.el | 18 | ||||
| -rw-r--r-- | lisp/gnus/nnir.el | 7 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 21 | ||||
| -rw-r--r-- | lisp/progmodes/subword.el | 111 |
8 files changed, 181 insertions, 62 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e86bc7f0a96..00a105b5142 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,25 @@ | |||
| 1 | 2013-03-27 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * facemenu.el (list-colors-callback): New defvar. | ||
| 4 | (list-colors-redisplay): New function. | ||
| 5 | (list-colors-display): Install list-colors-redisplay as the | ||
| 6 | revert-buffer-function. (Bug#14063) | ||
| 7 | |||
| 8 | 2013-03-27 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 9 | |||
| 10 | * minibuffer.el (completion-pcm--merge-completions): Make sure prefixes | ||
| 11 | and suffixes don't overlap (bug#14061). | ||
| 12 | |||
| 13 | * case-table.el: Use lexical-binding. | ||
| 14 | (case-table-get-table): New function. | ||
| 15 | (get-upcase-table): Use it. Mark as obsolete. Adjust callers. | ||
| 16 | |||
| 17 | 2013-03-27 Teodor Zlatanov <tzz@lifelogs.com> | ||
| 18 | |||
| 19 | * progmodes/subword.el: Add `superword-mode' to do word motion | ||
| 20 | over symbol_words (parallels and leverages `subword-mode' which | ||
| 21 | does word motion inside MixedCaseWords). | ||
| 22 | |||
| 1 | 2013-03-26 Stefan Monnier <monnier@iro.umontreal.ca> | 23 | 2013-03-26 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 24 | ||
| 3 | * desktop.el (desktop--v2s): Rename from desktop-internal-v2s. | 25 | * desktop.el (desktop--v2s): Rename from desktop-internal-v2s. |
diff --git a/lisp/case-table.el b/lisp/case-table.el index 711d4e4ec8c..7d4aa27de1c 100644 --- a/lisp/case-table.el +++ b/lisp/case-table.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; case-table.el --- code to extend the character set and support case tables | 1 | ;;; case-table.el --- code to extend the character set and support case tables -*- lexical-binding: t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1988, 1994, 2001-2013 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1988, 1994, 2001-2013 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -65,18 +65,26 @@ | |||
| 65 | (describe-vector description) | 65 | (describe-vector description) |
| 66 | (help-mode))))) | 66 | (help-mode))))) |
| 67 | 67 | ||
| 68 | (defun case-table-get-table (case-table table) | ||
| 69 | "Return the TABLE of CASE-TABLE. | ||
| 70 | TABLE can be `down', `up', `eqv' or `canon'." | ||
| 71 | (let ((slot-nb (cdr (assq table '((up . 0) (canon . 1) (eqv . 2)))))) | ||
| 72 | (or (if (eq table 'down) case-table) | ||
| 73 | (char-table-extra-slot case-table slot-nb) | ||
| 74 | ;; Setup all extra slots of CASE-TABLE by temporarily selecting | ||
| 75 | ;; it as the standard case table. | ||
| 76 | (let ((old (standard-case-table))) | ||
| 77 | (unwind-protect | ||
| 78 | (progn | ||
| 79 | (set-standard-case-table case-table) | ||
| 80 | (char-table-extra-slot case-table slot-nb)) | ||
| 81 | (or (eq case-table old) | ||
| 82 | (set-standard-case-table old))))))) | ||
| 83 | |||
| 68 | (defun get-upcase-table (case-table) | 84 | (defun get-upcase-table (case-table) |
| 69 | "Return the upcase table of CASE-TABLE." | 85 | "Return the upcase table of CASE-TABLE." |
| 70 | (or (char-table-extra-slot case-table 0) | 86 | (case-table-get-table case-table 'up)) |
| 71 | ;; Setup all extra slots of CASE-TABLE by temporarily selecting | 87 | (make-obsolete 'get-upcase-table 'case-table-get-table "24.4") |
| 72 | ;; it as the standard case table. | ||
| 73 | (let ((old (standard-case-table))) | ||
| 74 | (unwind-protect | ||
| 75 | (progn | ||
| 76 | (set-standard-case-table case-table) | ||
| 77 | (char-table-extra-slot case-table 0)) | ||
| 78 | (or (eq case-table old) | ||
| 79 | (set-standard-case-table old)))))) | ||
| 80 | 88 | ||
| 81 | (defun copy-case-table (case-table) | 89 | (defun copy-case-table (case-table) |
| 82 | (let ((copy (copy-sequence case-table)) | 90 | (let ((copy (copy-sequence case-table)) |
| @@ -97,7 +105,7 @@ It also modifies `standard-syntax-table' to | |||
| 97 | indicate left and right delimiters." | 105 | indicate left and right delimiters." |
| 98 | (aset table l l) | 106 | (aset table l l) |
| 99 | (aset table r r) | 107 | (aset table r r) |
| 100 | (let ((up (get-upcase-table table))) | 108 | (let ((up (case-table-get-table table 'up))) |
| 101 | (aset up l l) | 109 | (aset up l l) |
| 102 | (aset up r r)) | 110 | (aset up r r)) |
| 103 | ;; Clear out the extra slots so that they will be | 111 | ;; Clear out the extra slots so that they will be |
| @@ -117,7 +125,7 @@ It also modifies `standard-syntax-table' to give them the syntax of | |||
| 117 | word constituents." | 125 | word constituents." |
| 118 | (aset table uc lc) | 126 | (aset table uc lc) |
| 119 | (aset table lc lc) | 127 | (aset table lc lc) |
| 120 | (let ((up (get-upcase-table table))) | 128 | (let ((up (case-table-get-table table 'up))) |
| 121 | (aset up uc uc) | 129 | (aset up uc uc) |
| 122 | (aset up lc uc)) | 130 | (aset up lc uc)) |
| 123 | ;; Clear out the extra slots so that they will be | 131 | ;; Clear out the extra slots so that they will be |
| @@ -132,7 +140,7 @@ word constituents." | |||
| 132 | It also modifies `standard-syntax-table' to give them the syntax of | 140 | It also modifies `standard-syntax-table' to give them the syntax of |
| 133 | word constituents." | 141 | word constituents." |
| 134 | (aset table lc lc) | 142 | (aset table lc lc) |
| 135 | (let ((up (get-upcase-table table))) | 143 | (let ((up (case-table-get-table table 'up))) |
| 136 | (aset up uc uc) | 144 | (aset up uc uc) |
| 137 | (aset up lc uc)) | 145 | (aset up lc uc)) |
| 138 | ;; Clear out the extra slots so that they will be | 146 | ;; Clear out the extra slots so that they will be |
| @@ -148,7 +156,7 @@ It also modifies `standard-syntax-table' to give them the syntax of | |||
| 148 | word constituents." | 156 | word constituents." |
| 149 | (aset table uc lc) | 157 | (aset table uc lc) |
| 150 | (aset table lc lc) | 158 | (aset table lc lc) |
| 151 | (let ((up (get-upcase-table table))) | 159 | (let ((up (case-table-get-table table 'up))) |
| 152 | (aset up uc uc)) | 160 | (aset up uc uc)) |
| 153 | ;; Clear out the extra slots so that they will be | 161 | ;; Clear out the extra slots so that they will be |
| 154 | ;; recomputed from the main (downcase) table and upcase table. | 162 | ;; recomputed from the main (downcase) table and upcase table. |
| @@ -164,7 +172,7 @@ that will be used as the downcase part of a case table. | |||
| 164 | It also modifies `standard-syntax-table'. | 172 | It also modifies `standard-syntax-table'. |
| 165 | SYNTAX should be \" \", \"w\", \".\" or \"_\"." | 173 | SYNTAX should be \" \", \"w\", \".\" or \"_\"." |
| 166 | (aset table c c) | 174 | (aset table c c) |
| 167 | (let ((up (get-upcase-table table))) | 175 | (let ((up (case-table-get-table table 'up))) |
| 168 | (aset up c c)) | 176 | (aset up c c)) |
| 169 | ;; Clear out the extra slots so that they will be | 177 | ;; Clear out the extra slots so that they will be |
| 170 | ;; recomputed from the main (downcase) table and upcase table. | 178 | ;; recomputed from the main (downcase) table and upcase table. |
diff --git a/lisp/facemenu.el b/lisp/facemenu.el index e86c1c23d66..9a66edd28fc 100644 --- a/lisp/facemenu.el +++ b/lisp/facemenu.el | |||
| @@ -513,12 +513,23 @@ filter out the color from the output." | |||
| 513 | (* (nth 1 c-rgb) 0.7151522) | 513 | (* (nth 1 c-rgb) 0.7151522) |
| 514 | (* (nth 2 c-rgb) 0.0721750)))))) | 514 | (* (nth 2 c-rgb) 0.0721750)))))) |
| 515 | 515 | ||
| 516 | (defvar list-colors-callback nil | ||
| 517 | "Value of CALLBACK arg passed to `list-colors-display'; internal use.") | ||
| 518 | |||
| 519 | (defun list-colors-redisplay (_ignore-auto _noconfirm) | ||
| 520 | "Redisplay the colors using `list-colors-sort'. | ||
| 521 | |||
| 522 | This is installed as a `revert-buffer-function' in the *Colors* buffer." | ||
| 523 | (list-colors-display nil (buffer-name) list-colors-callback)) | ||
| 524 | |||
| 516 | (defun list-colors-display (&optional list buffer-name callback) | 525 | (defun list-colors-display (&optional list buffer-name callback) |
| 517 | "Display names of defined colors, and show what they look like. | 526 | "Display names of defined colors, and show what they look like. |
| 518 | If the optional argument LIST is non-nil, it should be a list of | 527 | If the optional argument LIST is non-nil, it should be a list of |
| 519 | colors to display. Otherwise, this command computes a list of | 528 | colors to display. Otherwise, this command computes a list of |
| 520 | colors that the current display can handle. Customize | 529 | colors that the current display can handle. Customize |
| 521 | `list-colors-sort' to change the order in which colors are shown. | 530 | `list-colors-sort' to change the order in which colors are shown. |
| 531 | Type `g' or \\[revert-buffer] after customizing `list-colors-sort' | ||
| 532 | to redisplay colors in the new order. | ||
| 522 | 533 | ||
| 523 | If the optional argument BUFFER-NAME is nil, it defaults to *Colors*. | 534 | If the optional argument BUFFER-NAME is nil, it defaults to *Colors*. |
| 524 | 535 | ||
| @@ -566,7 +577,9 @@ color. The function should accept a single argument, the color name." | |||
| 566 | (erase-buffer) | 577 | (erase-buffer) |
| 567 | (list-colors-print list callback) | 578 | (list-colors-print list callback) |
| 568 | (set-buffer-modified-p nil) | 579 | (set-buffer-modified-p nil) |
| 569 | (setq truncate-lines t))) | 580 | (setq truncate-lines t) |
| 581 | (setq-local list-colors-callback callback) | ||
| 582 | (setq revert-buffer-function 'list-colors-redisplay))) | ||
| 570 | (when callback | 583 | (when callback |
| 571 | (pop-to-buffer buffer-name) | 584 | (pop-to-buffer buffer-name) |
| 572 | (message "Click on a color to select it."))) | 585 | (message "Click on a color to select it."))) |
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 9fffc4f1a45..cbfb0109aec 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2013-03-27 Andrew Cohen <cohen@bu.edu> | ||
| 2 | |||
| 3 | * gnus-msg.el (gnus-setup-message): When replying from an nnir summary | ||
| 4 | buffer use the posting-style and gcc of the original article group. | ||
| 5 | (gnus-inews-insert-gcc): Don't set gcc-self for virtual groups. | ||
| 6 | |||
| 7 | * nnir.el: Fix byte-compile warning. nnoo-define-skeleton should come | ||
| 8 | after other deffoos. | ||
| 9 | |||
| 1 | 2013-03-26 Andrew Cohen <cohen@bu.edu> | 10 | 2013-03-26 Andrew Cohen <cohen@bu.edu> |
| 2 | 11 | ||
| 3 | * nnir.el: Major rewrite. Cleaner separation between searches and group | 12 | * nnir.el: Major rewrite. Cleaner separation between searches and group |
diff --git a/lisp/gnus/gnus-msg.el b/lisp/gnus/gnus-msg.el index f7b2d8b99d9..067465b0e6f 100644 --- a/lisp/gnus/gnus-msg.el +++ b/lisp/gnus/gnus-msg.el | |||
| @@ -426,15 +426,24 @@ Thank you for your help in stamping out bugs. | |||
| 426 | `(let ((,winconf (current-window-configuration)) | 426 | `(let ((,winconf (current-window-configuration)) |
| 427 | (,winconf-name gnus-current-window-configuration) | 427 | (,winconf-name gnus-current-window-configuration) |
| 428 | (,buffer (buffer-name (current-buffer))) | 428 | (,buffer (buffer-name (current-buffer))) |
| 429 | (,article gnus-article-reply) | 429 | (,article (or (when (and |
| 430 | (string-match "^nnir:" gnus-newsgroup-name) | ||
| 431 | gnus-article-reply) | ||
| 432 | (nnir-article-number gnus-article-reply)) | ||
| 433 | gnus-article-reply)) | ||
| 430 | (,yanked gnus-article-yanked-articles) | 434 | (,yanked gnus-article-yanked-articles) |
| 431 | (,group gnus-newsgroup-name) | 435 | (,group (or (when (and |
| 436 | (string-match "^nnir:" gnus-newsgroup-name) | ||
| 437 | gnus-article-reply) | ||
| 438 | (nnir-article-group gnus-article-reply)) | ||
| 439 | gnus-newsgroup-name)) | ||
| 432 | (message-header-setup-hook | 440 | (message-header-setup-hook |
| 433 | (copy-sequence message-header-setup-hook)) | 441 | (copy-sequence message-header-setup-hook)) |
| 434 | (mbl mml-buffer-list) | 442 | (mbl mml-buffer-list) |
| 435 | (message-mode-hook (copy-sequence message-mode-hook))) | 443 | (message-mode-hook (copy-sequence message-mode-hook))) |
| 436 | (setq mml-buffer-list nil) | 444 | (setq mml-buffer-list nil) |
| 437 | (add-hook 'message-header-setup-hook 'gnus-inews-insert-gcc) | 445 | (add-hook 'message-header-setup-hook (lambda () |
| 446 | (gnus-inews-insert-gcc ,group))) | ||
| 438 | ;; message-newsreader and message-mailer were formerly set in | 447 | ;; message-newsreader and message-mailer were formerly set in |
| 439 | ;; gnus-inews-add-send-actions, but this is too late when | 448 | ;; gnus-inews-add-send-actions, but this is too late when |
| 440 | ;; message-generate-headers-first is used. --ansel | 449 | ;; message-generate-headers-first is used. --ansel |
| @@ -1706,7 +1715,8 @@ this is a reply." | |||
| 1706 | (group (when group (gnus-group-decoded-name group))) | 1715 | (group (when group (gnus-group-decoded-name group))) |
| 1707 | (var (or gnus-outgoing-message-group gnus-message-archive-group)) | 1716 | (var (or gnus-outgoing-message-group gnus-message-archive-group)) |
| 1708 | (gcc-self-val | 1717 | (gcc-self-val |
| 1709 | (and group (gnus-group-find-parameter group 'gcc-self))) | 1718 | (and group (gnus-group-find-parameter group 'gcc-self) |
| 1719 | (not (gnus-virtual-group-p group)))) | ||
| 1710 | result | 1720 | result |
| 1711 | (groups | 1721 | (groups |
| 1712 | (cond | 1722 | (cond |
diff --git a/lisp/gnus/nnir.el b/lisp/gnus/nnir.el index cabd08b0653..a48c6043e82 100644 --- a/lisp/gnus/nnir.el +++ b/lisp/gnus/nnir.el | |||
| @@ -886,7 +886,7 @@ skips all prompting." | |||
| 886 | ;; (car (assoc '(nnir "nnir-ephemeral" (nnir-address "nnir")) | 886 | ;; (car (assoc '(nnir "nnir-ephemeral" (nnir-address "nnir")) |
| 887 | ;; gnus-opened-servers)))) | 887 | ;; gnus-opened-servers)))) |
| 888 | 888 | ||
| 889 | (nnoo-define-skeleton nnir) | 889 | |
| 890 | 890 | ||
| 891 | 891 | ||
| 892 | (defmacro nnir-add-result (dirnam artno score prefix server artlist) | 892 | (defmacro nnir-add-result (dirnam artno score prefix server artlist) |
| @@ -1880,6 +1880,11 @@ article came from is also searched." | |||
| 1880 | (nnir-request-update-info pgroup (gnus-get-info pgroup))) | 1880 | (nnir-request-update-info pgroup (gnus-get-info pgroup))) |
| 1881 | t)) | 1881 | t)) |
| 1882 | 1882 | ||
| 1883 | (deffoo nnir-request-close () | ||
| 1884 | t) | ||
| 1885 | |||
| 1886 | |||
| 1887 | (nnoo-define-skeleton nnir) | ||
| 1883 | 1888 | ||
| 1884 | ;; The end. | 1889 | ;; The end. |
| 1885 | (provide 'nnir) | 1890 | (provide 'nnir) |
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index ec237f0f664..016b16d0740 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -2997,12 +2997,21 @@ the same set of elements." | |||
| 2997 | ;; here any more. | 2997 | ;; here any more. |
| 2998 | (unless unique | 2998 | (unless unique |
| 2999 | (push elem res) | 2999 | (push elem res) |
| 3000 | (when (memq elem '(star point prefix)) | 3000 | ;; Extract common suffix additionally to common prefix. |
| 3001 | ;; Extract common suffix additionally to common prefix. | 3001 | ;; Don't do it for `any' since it could lead to a merged |
| 3002 | ;; Only do it for `point', `star', and `prefix' since for | 3002 | ;; completion that doesn't itself match the candidates. |
| 3003 | ;; `any' it could lead to a merged completion that | 3003 | (when (and (memq elem '(star point prefix)) |
| 3004 | ;; doesn't itself match the candidates. | 3004 | ;; If prefix is one of the completions, there's no |
| 3005 | (let ((suffix (completion--common-suffix comps))) | 3005 | ;; suffix left to find. |
| 3006 | (not (assoc-string prefix comps t))) | ||
| 3007 | (let ((suffix | ||
| 3008 | (completion--common-suffix | ||
| 3009 | (if (zerop (length prefix)) comps | ||
| 3010 | ;; Ignore the chars in the common prefix, so we | ||
| 3011 | ;; don't merge '("abc" "abbc") as "ab*bc". | ||
| 3012 | (let ((skip (length prefix))) | ||
| 3013 | (mapcar (lambda (str) (substring str skip)) | ||
| 3014 | comps)))))) | ||
| 3006 | (cl-assert (stringp suffix)) | 3015 | (cl-assert (stringp suffix)) |
| 3007 | (unless (equal suffix "") | 3016 | (unless (equal suffix "") |
| 3008 | (push suffix res))))) | 3017 | (push suffix res))))) |
diff --git a/lisp/progmodes/subword.el b/lisp/progmodes/subword.el index 80e632c6ef6..24abfa8a053 100644 --- a/lisp/progmodes/subword.el +++ b/lisp/progmodes/subword.el | |||
| @@ -26,7 +26,8 @@ | |||
| 26 | 26 | ||
| 27 | ;; This package provides `subword' oriented commands and a minor mode | 27 | ;; This package provides `subword' oriented commands and a minor mode |
| 28 | ;; (`subword-mode') that substitutes the common word handling | 28 | ;; (`subword-mode') that substitutes the common word handling |
| 29 | ;; functions with them. | 29 | ;; functions with them. It also provides the `superword-mode' minor |
| 30 | ;; mode that treats symbols as words, the opposite of `subword-mode'. | ||
| 30 | 31 | ||
| 31 | ;; In spite of GNU Coding Standards, it is popular to name a symbol by | 32 | ;; In spite of GNU Coding Standards, it is popular to name a symbol by |
| 32 | ;; mixing uppercase and lowercase letters, e.g. "GtkWidget", | 33 | ;; mixing uppercase and lowercase letters, e.g. "GtkWidget", |
| @@ -43,12 +44,13 @@ | |||
| 43 | 44 | ||
| 44 | ;; The subword oriented commands defined in this package recognize | 45 | ;; The subword oriented commands defined in this package recognize |
| 45 | ;; subwords in a nomenclature to move between them and to edit them as | 46 | ;; subwords in a nomenclature to move between them and to edit them as |
| 46 | ;; words. | 47 | ;; words. You also get a mode to treat symbols as words instead, |
| 48 | ;; called `superword-mode' (the opposite of `subword-mode'). | ||
| 47 | 49 | ||
| 48 | ;; In the minor mode, all common key bindings for word oriented | 50 | ;; In the minor mode, all common key bindings for word oriented |
| 49 | ;; commands are overridden by the subword oriented commands: | 51 | ;; commands are overridden by the subword oriented commands: |
| 50 | 52 | ||
| 51 | ;; Key Word oriented command Subword oriented command | 53 | ;; Key Word oriented command Subword oriented command (also superword) |
| 52 | ;; ============================================================ | 54 | ;; ============================================================ |
| 53 | ;; M-f `forward-word' `subword-forward' | 55 | ;; M-f `forward-word' `subword-forward' |
| 54 | ;; M-b `backward-word' `subword-backward' | 56 | ;; M-b `backward-word' `subword-backward' |
| @@ -67,8 +69,13 @@ | |||
| 67 | ;; To make the mode turn on automatically, put the following code in | 69 | ;; To make the mode turn on automatically, put the following code in |
| 68 | ;; your .emacs: | 70 | ;; your .emacs: |
| 69 | ;; | 71 | ;; |
| 70 | ;; (add-hook 'c-mode-common-hook | 72 | ;; (add-hook 'c-mode-common-hook 'subword-mode) |
| 71 | ;; (lambda () (subword-mode 1))) | 73 | ;; |
| 74 | |||
| 75 | ;; To make the mode turn `superword-mode' on automatically for | ||
| 76 | ;; only some modes, put the following code in your .emacs: | ||
| 77 | ;; | ||
| 78 | ;; (add-hook 'c-mode-common-hook 'superword-mode) | ||
| 72 | ;; | 79 | ;; |
| 73 | 80 | ||
| 74 | ;; Acknowledgment: | 81 | ;; Acknowledgment: |
| @@ -98,7 +105,8 @@ | |||
| 98 | (let ((map (make-sparse-keymap))) | 105 | (let ((map (make-sparse-keymap))) |
| 99 | (dolist (cmd '(forward-word backward-word mark-word kill-word | 106 | (dolist (cmd '(forward-word backward-word mark-word kill-word |
| 100 | backward-kill-word transpose-words | 107 | backward-kill-word transpose-words |
| 101 | capitalize-word upcase-word downcase-word)) | 108 | capitalize-word upcase-word downcase-word |
| 109 | left-word right-word)) | ||
| 102 | (let ((othercmd (let ((name (symbol-name cmd))) | 110 | (let ((othercmd (let ((name (symbol-name cmd))) |
| 103 | (string-match "\\([[:alpha:]-]+\\)-word[s]?" name) | 111 | (string-match "\\([[:alpha:]-]+\\)-word[s]?" name) |
| 104 | (intern (concat "subword-" (match-string 1 name)))))) | 112 | (intern (concat "subword-" (match-string 1 name)))))) |
| @@ -133,9 +141,8 @@ subwords in a nomenclature to move between subwords and to edit them | |||
| 133 | as words. | 141 | as words. |
| 134 | 142 | ||
| 135 | \\{subword-mode-map}" | 143 | \\{subword-mode-map}" |
| 136 | nil | 144 | :lighter " ," |
| 137 | nil | 145 | (when subword-mode (superword-mode -1))) |
| 138 | subword-mode-map) | ||
| 139 | 146 | ||
| 140 | (define-obsolete-function-alias 'c-subword-mode 'subword-mode "23.2") | 147 | (define-obsolete-function-alias 'c-subword-mode 'subword-mode "23.2") |
| 141 | 148 | ||
| @@ -161,6 +168,8 @@ Optional argument ARG is the same as for `forward-word'." | |||
| 161 | 168 | ||
| 162 | (put 'subword-forward 'CUA 'move) | 169 | (put 'subword-forward 'CUA 'move) |
| 163 | 170 | ||
| 171 | (defalias 'subword-right 'subword-forward) | ||
| 172 | |||
| 164 | (defun subword-backward (&optional arg) | 173 | (defun subword-backward (&optional arg) |
| 165 | "Do the same as `backward-word' but on subwords. | 174 | "Do the same as `backward-word' but on subwords. |
| 166 | See the command `subword-mode' for a description of subwords. | 175 | See the command `subword-mode' for a description of subwords. |
| @@ -168,6 +177,8 @@ Optional argument ARG is the same as for `backward-word'." | |||
| 168 | (interactive "p") | 177 | (interactive "p") |
| 169 | (subword-forward (- (or arg 1)))) | 178 | (subword-forward (- (or arg 1)))) |
| 170 | 179 | ||
| 180 | (defalias 'subword-left 'subword-backward) | ||
| 181 | |||
| 171 | (defun subword-mark (arg) | 182 | (defun subword-mark (arg) |
| 172 | "Do the same as `mark-word' but on subwords. | 183 | "Do the same as `mark-word' but on subwords. |
| 173 | See the command `subword-mode' for a description of subwords. | 184 | See the command `subword-mode' for a description of subwords. |
| @@ -254,41 +265,73 @@ Optional argument ARG is the same as for `capitalize-word'." | |||
| 254 | (unless advance | 265 | (unless advance |
| 255 | (goto-char start)))) | 266 | (goto-char start)))) |
| 256 | 267 | ||
| 268 | |||
| 269 | |||
| 270 | (defvar superword-mode-map subword-mode-map | ||
| 271 | "Keymap used in `superword-mode' minor mode.") | ||
| 272 | |||
| 273 | ;;;###autoload | ||
| 274 | (define-minor-mode superword-mode | ||
| 275 | "Toggle superword movement and editing (Superword mode). | ||
| 276 | With a prefix argument ARG, enable Superword mode if ARG is | ||
| 277 | positive, and disable it otherwise. If called from Lisp, enable | ||
| 278 | the mode if ARG is omitted or nil. | ||
| 279 | |||
| 280 | Superword mode is a buffer-local minor mode. Enabling it remaps | ||
| 281 | word-based editing commands to superword-based commands that | ||
| 282 | treat symbols as words, e.g. \"this_is_a_symbol\". | ||
| 283 | |||
| 284 | The superword oriented commands activated in this minor mode | ||
| 285 | recognize symbols as superwords to move between superwords and to | ||
| 286 | edit them as words. | ||
| 287 | |||
| 288 | \\{superword-mode-map}" | ||
| 289 | :lighter " ²" | ||
| 290 | (when superword-mode (subword-mode -1))) | ||
| 291 | |||
| 292 | ;;;###autoload | ||
| 293 | (define-global-minor-mode global-superword-mode superword-mode | ||
| 294 | (lambda () (superword-mode 1))) | ||
| 257 | 295 | ||
| 258 | 296 | ||
| 259 | ;; | 297 | ;; |
| 260 | ;; Internal functions | 298 | ;; Internal functions |
| 261 | ;; | 299 | ;; |
| 262 | (defun subword-forward-internal () | 300 | (defun subword-forward-internal () |
| 263 | (if (and | 301 | (if superword-mode |
| 264 | (save-excursion | 302 | (forward-symbol 1) |
| 265 | (let ((case-fold-search nil)) | 303 | (if (and |
| 266 | (re-search-forward subword-forward-regexp nil t))) | 304 | (save-excursion |
| 267 | (> (match-end 0) (point))) | 305 | (let ((case-fold-search nil)) |
| 268 | (goto-char | 306 | (re-search-forward subword-forward-regexp nil t))) |
| 269 | (cond | 307 | (> (match-end 0) (point))) |
| 270 | ((< 1 (- (match-end 2) (match-beginning 2))) | 308 | (goto-char |
| 271 | (1- (match-end 2))) | 309 | (cond |
| 272 | (t | 310 | ((< 1 (- (match-end 2) (match-beginning 2))) |
| 273 | (match-end 0)))) | 311 | (1- (match-end 2))) |
| 274 | (forward-word 1))) | 312 | (t |
| 275 | 313 | (match-end 0)))) | |
| 314 | (forward-word 1)))) | ||
| 276 | 315 | ||
| 277 | (defun subword-backward-internal () | 316 | (defun subword-backward-internal () |
| 278 | (if (save-excursion | 317 | (if superword-mode |
| 279 | (let ((case-fold-search nil)) | 318 | (forward-symbol -1) |
| 280 | (re-search-backward subword-backward-regexp nil t))) | 319 | (if (save-excursion |
| 281 | (goto-char | 320 | (let ((case-fold-search nil)) |
| 282 | (cond | 321 | (re-search-backward subword-backward-regexp nil t))) |
| 283 | ((and (match-end 3) | 322 | (goto-char |
| 284 | (< 1 (- (match-end 3) (match-beginning 3))) | 323 | (cond |
| 285 | (not (eq (point) (match-end 3)))) | 324 | ((and (match-end 3) |
| 286 | (1- (match-end 3))) | 325 | (< 1 (- (match-end 3) (match-beginning 3))) |
| 287 | (t | 326 | (not (eq (point) (match-end 3)))) |
| 288 | (1+ (match-beginning 0))))) | 327 | (1- (match-end 3))) |
| 289 | (backward-word 1))) | 328 | (t |
| 329 | (1+ (match-beginning 0))))) | ||
| 330 | (backward-word 1)))) | ||
| 290 | 331 | ||
| 291 | 332 | ||
| 333 | |||
| 292 | (provide 'subword) | 334 | (provide 'subword) |
| 335 | (provide 'superword) | ||
| 293 | 336 | ||
| 294 | ;;; subword.el ends here | 337 | ;;; subword.el ends here |