GNU bug report logs - #14602
Yank and delete characters in word and symbol isearch

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> jurta.org>

Date: Wed, 12 Jun 2013 21:30:03 UTC

Severity: normal

Tags: patch

Done: Daniel Colascione <dancol <at> dancol.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14602 in the body.
You can then email your comments to 14602 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#14602; Package emacs. (Wed, 12 Jun 2013 21:30:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> jurta.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 12 Jun 2013 21:30:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: bug-gnu-emacs <at> gnu.org
Subject: Yank and delete characters in word and symbol isearch
Date: Wed, 12 Jun 2013 23:57:04 +0300
As found in http://lists.gnu.org/archive/html/emacs-devel/2013-06/msg00390.html
the currently existing commands `isearch-yank-char' and `isearch-del-char'
fail to yank and delete characters in a word/symbol search.

The test case is typing `M-s w C-M-y C-M-y ... C-M-w C-M-w ...'
in the middle of a word/symbol or at the beginning/end of a word/symbol.

To remove the failure to yank a character in the middle of a word/symbol
it helps to lax the regexp at both ends of the word/symbol.

And to remove the failure to yank a character at the beginning/end
of a word/symbol it helps to match leading/trailing whitespace
at the word/symbol boundaries as well.

Then both `word-search-regexp' and `isearch-symbol-regexp' could share
the same body with the difference where the former uses word-based regexps
with \\<, \\> and \\W, and the latter uses symbol-based regexps with
\\_< and \\_>.

The remaining problem is how to translate \\W to the symbol-based regexp that
will match a non-word non-symbol character.  The only solution that I found is
to list all possible syntaxes except word and symbol syntax.

I tested this and it successfully passes all tests.

=== modified file 'lisp/isearch.el'
--- lisp/isearch.el	2013-06-06 06:23:19 +0000
+++ lisp/isearch.el	2013-06-12 20:48:17 +0000
@@ -1545,12 +1649,15 @@ (defun word-search-regexp (string &optio
 
 Used in `word-search-forward', `word-search-backward',
 `word-search-forward-lax', `word-search-backward-lax'."
-  (if (string-match-p "^\\W*$" string)
-      ""
-    (concat
-     "\\b"
-     (mapconcat 'identity (split-string string "\\W+" t) "\\W+")
-     (if (or (not lax) (string-match-p "\\W$" string)) "\\b"))))
+  (cond
+   ((equal string "") "")
+   ((string-match-p "\\`\\W+\\'" string) "\\W+")
+   (t (concat
+       (if (string-match-p "\\`\\W" string) "\\W+"
+	 (unless lax "\\<"))
+       (mapconcat 'regexp-quote (split-string string "\\W+" t) "\\W+")
+       (if (string-match-p "\\W\\'" string) "\\W+"
+	 (unless lax "\\>"))))))
 
 (defun word-search-backward (string &optional bound noerror count)
   "Search backward from point for STRING, ignoring differences in punctuation.
@@ -1627,7 +1733,17 @@ (defun isearch-symbol-regexp (string &op
   "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 "\\_>")))
+  (let ((not-word-symbol-re
+	 "\\(?:\\s-\\|\\s.\\|\\s(\\|\\s)\\|\\s\"\\|\\s\\\\|\\s/\\|\\s$\\|\\s'\\|\\s<\\|\\s>\\|\\s@\\|\\s!\\|\\s|\\)+"))
+    (cond
+     ((equal string "") "")
+     ((string-match-p (format "\\`%s\\'" not-word-symbol-re) string) not-word-symbol-re)
+     (t (concat
+	 (if (string-match-p (format "\\`%s" not-word-symbol-re) string) not-word-symbol-re
+	   (unless lax "\\_<"))
+	 (mapconcat 'regexp-quote (split-string string not-word-symbol-re t) not-word-symbol-re)
+	 (if (string-match-p (format "%s\\'" not-word-symbol-re) string) not-word-symbol-re
+	   (unless lax "\\_>")))))))
 
 (put 'isearch-symbol-regexp 'isearch-message-prefix "symbol ")
 




Reply sent to Daniel Colascione <dancol <at> dancol.org>:
You have taken responsibility. (Sun, 23 Mar 2014 06:39:02 GMT) Full text and rfc822 format available.

Notification sent to Juri Linkov <juri <at> jurta.org>:
bug acknowledged by developer. (Sun, 23 Mar 2014 06:39:06 GMT) Full text and rfc822 format available.

Message #10 received at 14602-done <at> debbugs.gnu.org (full text, mbox):

From: Daniel Colascione <dancol <at> dancol.org>
To: 14602-done <at> debbugs.gnu.org
Subject: Done
Date: Sat, 22 Mar 2014 23:37:53 -0700
[Message part 1 (text/plain, inline)]
Worksforme

[signature.asc (application/pgp-signature, attachment)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 20 Apr 2014 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 34 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.