emacs-devel
[Top][All Lists]
Advanced

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

Annoying call to error in goto-history-element


From: Geoff Gole
Subject: Annoying call to error in goto-history-element
Date: Tue, 7 Dec 2010 07:48:28 +0800

When moving through the history of find-file, running into the end of
the history will result in an error message briefly and annoyingly
obscuring the minibuffer. To see this, emacs -q C-x C-f <up>. The
cause is calls to error in goto-history-element.

It looks like in place of error we could call minibuffer-message and
exit the function (see patch below), which would make for a more
pleasant experience. Unfortunately that relies on the fact that the
callers of goto-history-element don't perform any real work after
their call to same, and that doesn't seem like a clean solution.

The only other thing I can think of is writing a macro
with-redirected-error-messages which would catch and redirect Lisp
errors into calls to minibuffer-message, and adding that to the
callers in question. I don't really like that either.

Thoughts?

--- -   2010-12-07 07:30:00.183679773 +0800
+++ simple.el   2010-12-07 07:26:02.000000000 +0800
@@ -1480,37 +1480,37 @@
              (minibuffer-contents-no-properties)))
     (if (< nabs minimum)
        (if minibuffer-default
-           (error "End of defaults; no next item")
-         (error "End of history; no default available")))
-    (if (> nabs (length (symbol-value minibuffer-history-variable)))
-       (error "Beginning of history; no preceding item"))
-    (unless (memq last-command '(next-history-element
-                                previous-history-element))
-      (let ((prompt-end (minibuffer-prompt-end)))
-       (set (make-local-variable 'minibuffer-temporary-goal-position)
-            (cond ((<= (point) prompt-end) prompt-end)
-                  ((eobp) nil)
-                  (t (point))))))
-    (goto-char (point-max))
-    (delete-minibuffer-contents)
-    (setq minibuffer-history-position nabs)
-    (cond ((< nabs 0)
-          (setq elt (if (listp minibuffer-default)
-                        (nth (1- (abs nabs)) minibuffer-default)
-                      minibuffer-default)))
-         ((= nabs 0)
-          (setq elt (or minibuffer-text-before-history ""))
-          (setq minibuffer-returned-to-present t)
-          (setq minibuffer-text-before-history nil))
-         (t (setq elt (nth (1- minibuffer-history-position)
-                           (symbol-value minibuffer-history-variable)))))
-    (insert
-     (if (and (eq minibuffer-history-sexp-flag (minibuffer-depth))
-             (not minibuffer-returned-to-present))
-        (let ((print-level nil))
-          (prin1-to-string elt))
-       elt))
-    (goto-char (or minibuffer-temporary-goal-position (point-max)))))
+           (minibuffer-message "End of defaults; no next item")
+         (minibuffer-message "End of history; no default available"))
+      (if (> nabs (length (symbol-value minibuffer-history-variable)))
+         (minibuffer-message "Beginning of history; no preceding item")
+       (unless (memq last-command '(next-history-element
+                                    previous-history-element))
+         (let ((prompt-end (minibuffer-prompt-end)))
+           (set (make-local-variable 'minibuffer-temporary-goal-position)
+                (cond ((<= (point) prompt-end) prompt-end)
+                      ((eobp) nil)
+                      (t (point))))))
+       (goto-char (point-max))
+       (delete-minibuffer-contents)
+       (setq minibuffer-history-position nabs)
+       (cond ((< nabs 0)
+              (setq elt (if (listp minibuffer-default)
+                            (nth (1- (abs nabs)) minibuffer-default)
+                          minibuffer-default)))
+             ((= nabs 0)
+              (setq elt (or minibuffer-text-before-history ""))
+              (setq minibuffer-returned-to-present t)
+              (setq minibuffer-text-before-history nil))
+             (t (setq elt (nth (1- minibuffer-history-position)
+                               (symbol-value minibuffer-history-variable)))))
+       (insert
+        (if (and (eq minibuffer-history-sexp-flag (minibuffer-depth))
+                 (not minibuffer-returned-to-present))
+            (let ((print-level nil))
+              (prin1-to-string elt))
+          elt))
+       (goto-char (or minibuffer-temporary-goal-position (point-max)))))))

 (defun next-history-element (n)
   "Puts next element of the minibuffer history in the minibuffer.



reply via email to

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