Subject: bug#15701: closed (Re: bug#15701: [PATCH] octave-mode: Handle empty lookfor result.)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 25 Oct 2013 00:52:02 +0000

Your bug report

#15701: [PATCH] octave-mode: Handle empty lookfor result.

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
15701: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15701
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#15701: [PATCH] octave-mode: Handle empty lookfor result.
From: Leo Liu <[email-masked]>
To: Rüdiger Sonderfeld <[email-masked]>
Cc: [email-masked]
Date: Fri, 25 Oct 2013 08:51:08 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

On 2013-10-25 00:58 +0800, Rüdiger Sonderfeld wrote:
> * lisp/progmodes/octave.el (octave-lookfor): Handle empty lookfor
>   result.  Ask user to retry using '-all' flag.

Committed with thanks.

Leo

Subject: [PATCH] octave-mode: Handle empty lookfor result.
From: Rüdiger Sonderfeld <[email-masked]>
To: [email-masked]
Cc: Leo Liu <[email-masked]>
Date: Thu, 24 Oct 2013 18:58:53 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

* lisp/progmodes/octave.el (octave-lookfor): Handle empty lookfor
  result.  Ask user to retry using '-all' flag.

Signed-off-by: Rüdiger Sonderfeld <[email-masked]>
---
 lisp/progmodes/octave.el | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index 899bf15..1803ea6 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -1724,20 +1724,32 @@ (defun octave-lookfor (str &optional all)
                  (if all "'-all', " "")
                  str)))
   (let ((lines inferior-octave-output-list))
-    (when (string-match "error: \\(.*\\)$" (car lines))
+    (when (and (stringp (car lines))
+               (string-match "error: \\(.*\\)$" (car lines)))
       (error "%s" (match-string 1 (car lines))))
     (with-help-window octave-help-buffer
-      (princ (mapconcat 'identity lines "\n"))
       (with-current-buffer octave-help-buffer
+        (if lines
+            (insert (mapconcat 'identity lines "\n"))
+          (insert (format "Nothing found for \"%s\".\n" str)))
         ;; Bound to t so that `help-buffer' returns current buffer for
         ;; `help-setup-xref'.
         (let ((help-xref-following t))
           (help-setup-xref (list 'octave-lookfor str all)
                            (called-interactively-p 'interactive)))
         (goto-char (point-min))
-        (while (re-search-forward "^\\([^[:blank:]]+\\) " nil 'noerror)
-          (make-text-button (match-beginning 1) (match-end 1)
-                            :type 'octave-help-function))
+        (when lines
+          (while (re-search-forward "^\\([^[:blank:]]+\\) " nil 'noerror)
+            (make-text-button (match-beginning 1) (match-end 1)
+                              :type 'octave-help-function)))
+        (unless all
+          (goto-char (point-max))
+          (insert "\nRetry with ")
+          (insert-text-button "'-all'"
+                              'follow-link t
+                              'action #'(lambda (b)
+                                          (octave-lookfor str '-all)))
+          (insert ".\n"))
         (octave-help-mode)))))
 
 (defcustom octave-source-directories nil
-- 
1.8.4