emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 3887c54: Throw a `search-failed' derived error in I


From: Noam Postavsky
Subject: [Emacs-diffs] master 3887c54: Throw a `search-failed' derived error in Info search
Date: Mon, 3 Apr 2017 19:49:28 -0400 (EDT)

branch: master
commit 3887c54544bc2e5f8c2e7c12973887f9b2b88c40
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Throw a `search-failed' derived error in Info search
    
    The original fix for Bug#6106 switched from signalling `search-failed'
    to `user-error'.  However, this breaks incremental searching over
    multiple nodes because the isearch code doesn't expect a `user-error'.
    
    * src/search.c (syms_of_search): New error, `user-search-failed',
    with `user-error' and `search-failed' as parents.
    * doc/lispref/errors.texi (Standard Errors): Document it.
    * etc/NEWS: Announce it.
    * lisp/info.el (Info-search): Use it instead of `user-error' so that
    isearch will handle failed searches correctly.
---
 doc/lispref/errors.texi |  6 ++++++
 etc/NEWS                |  4 ++++
 lisp/info.el            | 12 ++++++------
 src/search.c            | 10 ++++++++++
 4 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/doc/lispref/errors.texi b/doc/lispref/errors.texi
index 2ec1a10..1f67819 100644
--- a/doc/lispref/errors.texi
+++ b/doc/lispref/errors.texi
@@ -186,6 +186,12 @@ The message is @samp{Undefined color}.  @xref{Color Names}.
 @item user-error
 The message is the empty string.  @xref{Signaling Errors}.
 
address@hidden user-search-failed
+This is like @samp{search-failed}, but doesn't trigger the debugger,
+like @samp{user-error}.  @xref{Signaling Errors}, and @xref{Searching
+and Matching}.  This is used for searching in Info files, @xref{Search
+Text,,,info,Info}.
+
 @item void-function
 The message is @samp{Symbol's function definition is void}.
 @xref{Function Cells}.
diff --git a/etc/NEWS b/etc/NEWS
index bfd7d2b..fc07656 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1058,6 +1058,10 @@ its window gets deleted by 'delete-other-windows'.
 *** New command 'window-swap-states' swaps the states of two live
 windows.
 
++++
+*** New error type 'user-search-failed' like 'search-failed' but
+avoids debugger like 'user-error'.
+
 
 * Changes in Emacs 26.1 on Non-Free Operating Systems
 
diff --git a/lisp/info.el b/lisp/info.el
index a6bab29..81e5d29 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -1998,20 +1998,20 @@ If DIRECTION is `backward', search in the reverse 
direction."
                   Info-isearch-initial-node
                   bound
                   (and found (> found opoint-min) (< found opoint-max)))
-       (user-error "Search failed: `%s' (end of node)" regexp))
+       (signal 'user-search-failed (list regexp "(end of node)")))
 
       ;; If no subfiles, give error now.
       (unless (or found Info-current-subfile)
         (if isearch-mode
-            (user-error "Search failed: `%s' (end of manual)" regexp)
+            (signal 'user-search-failed (list regexp "end of manual"))
           (let ((search-spaces-regexp Info-search-whitespace-regexp))
             (unless (if backward
                         (re-search-backward regexp nil t)
                       (re-search-forward regexp nil t))
-              (user-error "Search failed: `%s'" regexp)))))
+              (signal 'user-seach-failed (list regexp))))))
 
       (if (and bound (not found))
-          (user-error "Search failed: `%s'" regexp))
+          (signal 'user-search-failed (list regexp)))
 
       (unless (or found bound)
        (unwind-protect
@@ -2055,8 +2055,8 @@ If DIRECTION is `backward', search in the reverse 
direction."
                    (setq list nil)))
              (if found
                  (message "")
-                (user-error "Search failed: `%s'%s"
-                            regexp (if isearch-mode " (end of manual)" ""))))
+                (signal 'user-search-failed
+                        `(,regexp ,@(if isearch-mode '("end of manual"))))))
          (if (not found)
              (progn (Info-read-subfile osubfile)
                     (goto-char opoint)
diff --git a/src/search.c b/src/search.c
index 33cb02a..c0deb57 100644
--- a/src/search.c
+++ b/src/search.c
@@ -3389,6 +3389,10 @@ syms_of_search (void)
   /* Error condition used for failing searches.  */
   DEFSYM (Qsearch_failed, "search-failed");
 
+  /* Error condition used for failing searches started by user, i.e.,
+     where failure should not invoke the debugger.  */
+  DEFSYM (Quser_search_failed, "user-search-failed");
+
   /* Error condition signaled when regexp compile_pattern fails.  */
   DEFSYM (Qinvalid_regexp, "invalid-regexp");
 
@@ -3397,6 +3401,12 @@ syms_of_search (void)
   Fput (Qsearch_failed, Qerror_message,
        build_pure_c_string ("Search failed"));
 
+  Fput (Quser_search_failed, Qerror_conditions,
+        listn (CONSTYPE_PURE, 4,
+               Quser_search_failed, Quser_error, Qsearch_failed, Qerror));
+  Fput (Quser_search_failed, Qerror_message,
+        build_pure_c_string ("Search failed"));
+
   Fput (Qinvalid_regexp, Qerror_conditions,
        listn (CONSTYPE_PURE, 2, Qinvalid_regexp, Qerror));
   Fput (Qinvalid_regexp, Qerror_message,



reply via email to

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