1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-27 10:54:40 +00:00

Use user-error where error is inappropriate

* help-mode.el (help-go-back, help-go-forward, help-follow):
* simple.el (yank-pop, pop-to-mark-command, exchange-point-and-mark):
* winner.el (winner-redo):
* windmove.el (windmove-do-window-select):
* register.el (jump-to-register, increment-register, insert-register)
(append-to-register, prepend-to-register):
* files.el (find-alternate-file, abort-if-file-too-large, write-file)
(set-visited-file-name):
* emacs-lisp/lisp.el (kill-backward-up-list):
Use user-error instead of error. (Bug#14480)
This commit is contained in:
Kelly Dean 2015-02-18 07:35:49 +00:00 committed by Artur Malabarba
parent ad6c1be923
commit 72f7eded97
8 changed files with 36 additions and 23 deletions

View File

@ -1,3 +1,16 @@
2015-02-18 Kelly Dean <kelly@prtime.org>
* help-mode.el (help-go-back, help-go-forward, help-follow):
* simple.el (yank-pop, pop-to-mark-command, exchange-point-and-mark):
* winner.el (winner-redo):
* windmove.el (windmove-do-window-select):
* register.el (jump-to-register, increment-register, insert-register)
(append-to-register, prepend-to-register):
* files.el (find-alternate-file, abort-if-file-too-large, write-file)
(set-visited-file-name):
* emacs-lisp/lisp.el (kill-backward-up-list):
Use user-error instead of error. (Bug#14480)
2015-02-18 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/checkdoc.el (checkdoc-show-diagnostics): Don't make bogus
@ -5,7 +18,7 @@
2015-02-16 Kelly Dean <kelly@prtime.org>
* lisp/files.el (insert-file-contents-literally): Fix docstring typo.
* files.el (insert-file-contents-literally): Fix docstring typo.
2015-02-16 Kelly Dean <kelly@prtime.org>

View File

@ -263,7 +263,7 @@ This command assumes point is not in a string or comment."
(backward-up-list arg)
(kill-sexp)
(insert current-sexp))
(error "Not at a sexp"))))
(user-error "Not at a sexp"))))
(defvar beginning-of-defun-function nil
"If non-nil, function for `beginning-of-defun-raw' to call.

View File

@ -1628,10 +1628,10 @@ killed."
(confirm-nonexistent-file-or-buffer) file-name)
t)))
(unless (run-hook-with-args-until-failure 'kill-buffer-query-functions)
(error "Aborted"))
(user-error "Aborted"))
(and (buffer-modified-p) buffer-file-name
(not (yes-or-no-p "Kill and replace the buffer without saving it? "))
(error "Aborted"))
(user-error "Aborted"))
(let ((obuf (current-buffer))
(ofile buffer-file-name)
(onum buffer-file-number)
@ -1844,7 +1844,7 @@ OP-TYPE specifies the file operation being performed (for message to user)."
(not (y-or-n-p (format "File %s is large (%s), really %s? "
(file-name-nondirectory filename)
(file-size-human-readable size) op-type))))
(error "Aborted")))
(user-error "Aborted")))
(defun warn-maybe-out-of-memory (size)
"Warn if an attempt to open file of SIZE bytes may run out of memory."
@ -3883,7 +3883,7 @@ the old visited file has been renamed to the new name FILENAME."
(not no-query)
(not (y-or-n-p (format "A buffer is visiting %s; proceed? "
filename)))
(error "Aborted")))
(user-error "Aborted")))
(or (equal filename buffer-file-name)
(progn
(and filename (lock-buffer filename))
@ -4007,7 +4007,7 @@ Interactively, confirmation is required unless you supply a prefix argument."
(listp last-nonmenu-event)
use-dialog-box))
(or (y-or-n-p (format "File `%s' exists; overwrite? " filename))
(error "Canceled")))
(user-error "Canceled")))
(set-visited-file-name filename (not confirm))))
(set-buffer-modified-p t)
;; Make buffer writable if file is writable.

View File

@ -724,14 +724,14 @@ BUFFER or FRAME."
(interactive)
(if help-xref-stack
(help-xref-go-back (current-buffer))
(error "No previous help buffer")))
(user-error "No previous help buffer")))
(defun help-go-forward ()
"Go back to next topic in this help buffer."
(interactive)
(if help-xref-forward-stack
(help-xref-go-forward (current-buffer))
(error "No next help buffer")))
(user-error "No next help buffer")))
(defun help-do-xref (_pos function args)
"Call the help cross-reference function FUNCTION with args ARGS.
@ -754,7 +754,7 @@ a proper [back] button."
For the cross-reference format, see `help-make-xrefs'."
(interactive)
(error "No cross-reference here"))
(user-error "No cross-reference here"))
(defun help-follow-symbol (&optional pos)
"In help buffer, show docs for symbol at POS, defaulting to point.

View File

@ -252,7 +252,7 @@ Interactively, reads the register using `register-read-with-preview'."
(goto-char (cadr val)))
((markerp val)
(or (marker-buffer val)
(error "That register's buffer no longer exists"))
(user-error "That register's buffer no longer exists"))
(switch-to-buffer (marker-buffer val))
(goto-char val))
((and (consp val) (eq (car val) 'file))
@ -260,11 +260,11 @@ Interactively, reads the register using `register-read-with-preview'."
((and (consp val) (eq (car val) 'file-query))
(or (find-buffer-visiting (nth 1 val))
(y-or-n-p (format "Visit file %s again? " (nth 1 val)))
(error "Register access aborted"))
(user-error "Register access aborted"))
(find-file (nth 1 val))
(goto-char (nth 2 val)))
(t
(error "Register doesn't contain a buffer position or configuration")))))
(user-error "Register doesn't contain a buffer position or configuration")))))
(defun register-swap-out ()
"Turn markers into file-query references when a buffer is killed."
@ -316,7 +316,7 @@ Interactively, reads the register using `register-read-with-preview'."
(set-register register (+ number register-val))))
((or (not register-val) (stringp register-val))
(append-to-register register (region-beginning) (region-end) prefix))
(t (error "Register does not contain a number or text")))))
(t (user-error "Register does not contain a number or text")))))
(defun view-register (register)
"Display what is contained in register named REGISTER.
@ -449,7 +449,7 @@ Interactively, reads the register using `register-read-with-preview'."
((and (markerp val) (marker-position val))
(princ (marker-position val) (current-buffer)))
(t
(error "Register does not contain text"))))
(user-error "Register does not contain text"))))
(if (not arg) (exchange-point-and-mark)))
(defun copy-to-register (register start end &optional delete-flag region)
@ -492,7 +492,7 @@ Interactively, reads the register using `register-read-with-preview'."
(set-register
register (cond ((not reg) text)
((stringp reg) (concat reg separator text))
(t (error "Register does not contain text")))))
(t (user-error "Register does not contain text")))))
(setq deactivate-mark t)
(cond (delete-flag
(delete-region start end))
@ -516,7 +516,7 @@ Interactively, reads the register using `register-read-with-preview'."
(set-register
register (cond ((not reg) text)
((stringp reg) (concat text separator reg))
(t (error "Register does not contain text")))))
(t (user-error "Register does not contain text")))))
(setq deactivate-mark t)
(cond (delete-flag
(delete-region start end))

View File

@ -4326,7 +4326,7 @@ When this command inserts killed text into the buffer, it honors
doc string for `insert-for-yank-1', which see."
(interactive "*p")
(if (not (eq last-command 'yank))
(error "Previous command was not a yank"))
(user-error "Previous command was not a yank"))
(setq this-command 'yank)
(unless arg (setq arg 1))
(let ((inhibit-read-only t)
@ -4958,7 +4958,7 @@ Start discarding off end if gets this big."
\(Does not affect global mark ring)."
(interactive)
(if (null (mark t))
(error "No mark set in this buffer")
(user-error "No mark set in this buffer")
(if (= (point) (mark t))
(message "Mark popped"))
(goto-char (mark t))
@ -5107,7 +5107,7 @@ mode temporarily."
(let ((omark (mark t))
(temp-highlight (eq (car-safe transient-mark-mode) 'only)))
(if (null omark)
(error "No mark set in this buffer"))
(user-error "No mark set in this buffer"))
(set-mark (point))
(goto-char omark)
(cond (temp-highlight

View File

@ -479,10 +479,10 @@ DIR, ARG, and WINDOW are handled as by `windmove-other-window-loc'.
If no window is at direction DIR, an error is signaled."
(let ((other-window (windmove-find-other-window dir arg window)))
(cond ((null other-window)
(error "No window %s from selected window" dir))
(user-error "No window %s from selected window" dir))
((and (window-minibuffer-p other-window)
(not (minibuffer-window-active-p other-window)))
(error "Minibuffer is inactive"))
(user-error "Minibuffer is inactive"))
(t
(select-window other-window)))))

View File

@ -415,7 +415,7 @@ In other words, \"undo\" changes in window configuration."
(ring-ref winner-pending-undo-ring 0)))
(unless (eq (selected-window) (minibuffer-window))
(message "Winner undid undo")))
(t (error "Previous command was not a `winner-undo'"))))
(t (user-error "Previous command was not a `winner-undo'"))))
(provide 'winner)
;;; winner.el ends here