emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r108417: * lisp/isearch.el (isearch-m


From: Juri Linkov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r108417: * lisp/isearch.el (isearch-mode-map): Bind `M-s _' to `isearch-toggle-symbol'.
Date: Tue, 29 May 2012 12:46:06 +0300
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 108417
fixes bug: http://debbugs.gnu.org/11381
committer: Juri Linkov <address@hidden>
branch nick: trunk
timestamp: Tue 2012-05-29 12:46:06 +0300
message:
  * lisp/isearch.el (isearch-mode-map): Bind `M-s _' to `isearch-toggle-symbol'.
  Bind `M-s c' to `isearch-toggle-case-fold'.
  (search-map): Bind `M-s _' to `isearch-forward-symbol'.
  (isearch-forward): Add `M-s _' to the docstring.
  (isearch-forward-symbol, isearch-toggle-case-fold)
  (isearch-symbol-regexp): New functions.
modified:
  etc/NEWS
  lisp/ChangeLog
  lisp/isearch.el
=== modified file 'etc/NEWS'
--- a/etc/NEWS  2012-05-28 03:42:18 +0000
+++ b/etc/NEWS  2012-05-29 09:46:06 +0000
@@ -81,6 +81,12 @@
 
 * Editing Changes in Emacs 24.2
 
+** Search changes
+
+*** Global `M-s _' starts a symbol (identifier) incremental search,
+and `M-s _' in Isearch toggles symbol search mode.
+`M-s c' in Isearch toggles search case-sensitivity.
+
 ** M-x move-to-column, if called interactively with no prefix arg, now
 prompts for a column number.
 

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-05-29 09:27:39 +0000
+++ b/lisp/ChangeLog    2012-05-29 09:46:06 +0000
@@ -1,5 +1,15 @@
 2012-05-29  Juri Linkov  <address@hidden>
 
+       * isearch.el (isearch-mode-map): Bind `M-s _' to
+       `isearch-toggle-symbol'.  Bind `M-s c' to
+       `isearch-toggle-case-fold'.
+       (search-map): Bind `M-s _' to `isearch-forward-symbol'.
+       (isearch-forward): Add `M-s _' to the docstring.
+       (isearch-forward-symbol, isearch-toggle-case-fold)
+       (isearch-symbol-regexp): New functions.  (Bug#11381)
+
+2012-05-29  Juri Linkov  <address@hidden>
+
        * isearch.el (isearch-word): Add docstring.  (Bug#11381)
        (isearch-occur, isearch-search-and-update): If `isearch-word' is
        a function, call it to get the regexp.

=== modified file 'lisp/isearch.el'
--- a/lisp/isearch.el   2012-05-29 09:27:39 +0000
+++ b/lisp/isearch.el   2012-05-29 09:46:06 +0000
@@ -501,8 +501,10 @@
     (define-key map "\M-r" 'isearch-toggle-regexp)
     (define-key map "\M-e" 'isearch-edit-string)
 
+    (define-key map "\M-sc" 'isearch-toggle-case-fold)
     (define-key map "\M-sr" 'isearch-toggle-regexp)
     (define-key map "\M-sw" 'isearch-toggle-word)
+    (define-key map "\M-s_" 'isearch-toggle-symbol)
 
     (define-key map [?\M-%] 'isearch-query-replace)
     (define-key map [?\C-\M-%] 'isearch-query-replace-regexp)
@@ -531,11 +533,11 @@
 (defvar isearch-forward nil)   ; Searching in the forward direction.
 (defvar isearch-regexp nil)    ; Searching for a regexp.
 (defvar isearch-word nil
-  "Regexp-based search mode for words.
+  "Regexp-based search mode for words/symbols.
 If t, do incremental search for a sequence of words, ignoring punctuation.
-If the value is a function, it is called to convert the search string
-to a regexp used by regexp search functions.  The property
-`isearch-message-prefix' put on this function specifies the
+If the value is a function (e.g. `isearch-symbol-regexp'), it is called to
+convert the search string to a regexp used by regexp search functions.
+The property `isearch-message-prefix' put on this function specifies the
 prefix string displyed in the search message.")
 
 (defvar isearch-cmds nil
@@ -622,6 +624,7 @@
 (define-key global-map "\C-r" 'isearch-backward)
 (define-key esc-map "\C-r" 'isearch-backward-regexp)
 (define-key search-map "w" 'isearch-forward-word)
+(define-key search-map "_" 'isearch-forward-symbol)
 
 ;; Entry points to isearch-mode.
 
@@ -661,6 +664,7 @@
 Type \\[isearch-toggle-case-fold] to toggle search case-sensitivity.
 Type \\[isearch-toggle-regexp] to toggle regular-expression mode.
 Type \\[isearch-toggle-word] to toggle word mode.
+Type \\[isearch-toggle-symbol] to toggle symbol mode.
 Type \\[isearch-edit-string] to edit the search string in the minibuffer.
 
 Also supported is a search ring of the previous 16 search strings.
@@ -728,6 +732,16 @@
   (interactive "P\np")
   (isearch-mode t nil nil (not no-recursive-edit) (null not-word)))
 
+(defun isearch-forward-symbol (&optional not-symbol no-recursive-edit)
+  "\
+Do incremental search forward for a symbol.
+The prefix argument is currently unused.
+Like ordinary incremental search except that your input is treated
+as a symbol surrounded by symbol boundary constructs \\_< and \\_>.
+See the command `isearch-forward' for more information."
+  (interactive "P\np")
+  (isearch-mode t nil nil (not no-recursive-edit) 'isearch-symbol-regexp))
+
 (defun isearch-backward (&optional regexp-p no-recursive-edit)
   "\
 Do incremental search backward.
@@ -1375,6 +1389,14 @@
   (setq isearch-success t isearch-adjusted t)
   (isearch-update))
 
+(defun isearch-toggle-symbol ()
+  "Toggle symbol searching on or off."
+  (interactive)
+  (setq isearch-word (unless (eq isearch-word 'isearch-symbol-regexp)
+                      'isearch-symbol-regexp))
+  (setq isearch-success t isearch-adjusted t)
+  (isearch-update))
+
 (defun isearch-toggle-case-fold ()
   "Toggle case folding in searching on or off."
   (interactive)
@@ -1476,6 +1498,16 @@
   (interactive "sWord search: ")
   (re-search-forward (word-search-regexp string t) bound noerror count))
 
+;; Symbol search
+
+(defun isearch-symbol-regexp (string &optional lax)
+  "Return a regexp which matches STRING as a symbol.
+Creates a regexp where STRING is surrounded by symbol delimiters \\_< and \\_>.
+If LAX is non-nil, the end of the string need not match a symbol boundary."
+  (concat "\\_<" (regexp-quote string) (unless lax "\\_>")))
+
+(put 'isearch-symbol-regexp 'isearch-message-prefix "symbol ")
+
 
 (defun isearch-query-replace (&optional delimited regexp-flag)
   "Start `query-replace' with string to replace from last search string.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]