]> git.eshelyaron.com Git - emacs.git/commitdiff
* list/emulation/viper: Use user-error for "Viper bell"
authorChristopher Wellons <wellons@nullprogram.com>
Sat, 9 Mar 2019 20:49:49 +0000 (15:49 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sat, 9 Mar 2019 20:49:49 +0000 (15:49 -0500)
Copyright-paperwork-exempt: yes

* lisp/emulation/viper-init.el (viper-ViperBell): New constant.
* lisp/emulation/viper-cmd.el (viper-prefix-arg-com)
(viper-forward-char, viper-backward-char, viper-goto-col)
(viper-find-char, viper-paren-match, viper-put-back, viper-Put-back)
(viper-delete-char, viper-mark-point, viper-goto-mark-subr):
* lisp/emulation/viper-ex.el (ex-delete): Use it and `user-error`.

lisp/emulation/viper-cmd.el
lisp/emulation/viper-ex.el
lisp/emulation/viper-init.el

index f041f25ae9a8af5fc4f3a2f36ef14ce245122f94..f52ce72a6d8a1d9df32da54f4bcef0f784b131c2 100644 (file)
@@ -1124,7 +1124,7 @@ as a Meta key and any number of multiple escapes are allowed."
          ;; it is an error.
          (progn
            ;; new com is (CHAR . OLDCOM)
-           (if (viper-memq-char char '(?# ?\")) (error "Viper bell"))
+           (if (viper-memq-char char '(?# ?\")) (user-error viper-ViperBell))
            (setq com (cons char com))
            (setq cont nil))
        ;; If com is nil we set com as char, and read more.  Again, if char is
@@ -1143,7 +1143,7 @@ as a Meta key and any number of multiple escapes are allowed."
               (let ((reg (read-char)))
                 (if (viper-valid-register reg)
                     (setq viper-use-register reg)
-                  (error "Viper bell"))
+                  (user-error viper-ViperBell))
                 (setq char (read-char))))
              (t
               (setq com char)
@@ -1165,7 +1165,7 @@ as a Meta key and any number of multiple escapes are allowed."
              (viper-regsuffix-command-p char)
              (viper= char ?!) ; bang command
              (viper= char ?g) ; the gg command (like G0)
-             (error "Viper bell"))
+             (user-error viper-ViperBell))
          (setq cmd-to-exec-at-end
                (viper-exec-form-in-vi
                 `(key-binding (char-to-string ,char)))))
@@ -1199,7 +1199,7 @@ as a Meta key and any number of multiple escapes are allowed."
         ((equal com '(?= . ?=)) (viper-line (cons value ?=)))
         ;; gg  acts as G0
         ((equal (car com) ?g)   (viper-goto-line 0))
-        (t (error "Viper bell")))))
+        (t (user-error viper-ViperBell)))))
 
     (if cmd-to-exec-at-end
        (progn
@@ -2609,9 +2609,9 @@ On reaching end of line, stop and signal error."
          ;; the forward motion before the 'viper-execute-com', but, of
          ;; course, 'dl' doesn't work on an empty line, so we have to
          ;; catch that condition before 'viper-execute-com'
-         (if (and (eolp) (bolp)) (error "Viper bell") (forward-char val))
+         (if (and (eolp) (bolp)) (user-error viper-ViperBell) (forward-char val))
          (if com (viper-execute-com 'viper-forward-char val com))
-         (if (eolp) (progn (backward-char 1) (error "Viper bell"))))
+         (if (eolp) (progn (backward-char 1) (user-error viper-ViperBell))))
       (forward-char val)
       (if com (viper-execute-com 'viper-forward-char val com)))))
 
@@ -2626,7 +2626,7 @@ On reaching beginning of line, stop and signal error."
     (if com (viper-move-marker-locally 'viper-com-point (point)))
     (if viper-ex-style-motion
        (progn
-         (if (bolp) (error "Viper bell") (backward-char val))
+         (if (bolp) (user-error viper-ViperBell) (backward-char val))
          (if com (viper-execute-com 'viper-backward-char val com)))
       (backward-char val)
       (if com (viper-execute-com 'viper-backward-char val com)))))
@@ -2953,7 +2953,7 @@ On reaching beginning of line, stop and signal error."
     (if com (viper-execute-com 'viper-goto-col val com))
     (save-excursion
       (end-of-line)
-      (if (> val (current-column)) (error "Viper bell")))
+      (if (> val (current-column)) (user-error viper-ViperBell)))
     ))
 
 
@@ -3084,7 +3084,7 @@ If point is on a widget or a button, simulate clicking on that widget/button."
 ;; If FORWARD then search is forward, otherwise backward.  OFFSET is used to
 ;; adjust point after search.
 (defun viper-find-char (arg char forward offset)
-  (or (char-or-string-p char) (error "Viper bell"))
+  (or (char-or-string-p char) (user-error viper-ViperBell))
   (let ((arg (if forward arg (- arg)))
        (cmd (if (eq viper-intermediate-command 'viper-repeat)
                 (nth 5 viper-d-com)
@@ -3424,7 +3424,7 @@ controlled by the sign of prefix numeric value."
             (if com (viper-move-marker-locally 'viper-com-point (point)))
             (backward-sexp 1)
             (if com (viper-execute-com 'viper-paren-match nil com)))
-           (t (error "Viper bell"))))))
+           (t (user-error viper-ViperBell))))))
 
 (defun viper-toggle-parse-sexp-ignore-comments ()
   (interactive)
@@ -4001,7 +4001,7 @@ Null string will repeat previous search."
            (let ((reg viper-use-register))
              (setq viper-use-register nil)
              (error viper-EmptyRegister reg))
-         (error "Viper bell")))
+         (user-error viper-ViperBell)))
     (setq viper-use-register nil)
     (if (viper-end-with-a-newline-p text)
        (progn
@@ -4051,7 +4051,7 @@ Null string will repeat previous search."
            (let ((reg viper-use-register))
              (setq viper-use-register nil)
              (error viper-EmptyRegister reg))
-         (error "Viper bell")))
+         (user-error viper-ViperBell)))
     (setq viper-use-register nil)
     (if (viper-end-with-a-newline-p text) (beginning-of-line))
     (viper-set-destructive-command
@@ -4096,7 +4096,7 @@ Null string will repeat previous search."
             (> val (viper-chars-in-region (point) (viper-line-pos 'end))))
        (setq val (viper-chars-in-region (point) (viper-line-pos 'end))))
     (if (and viper-ex-style-motion (eolp))
-       (if (bolp) (error "Viper bell") (setq val 0))) ; not bol---simply back 1 ch
+       (if (bolp) (user-error viper-ViperBell) (setq val 0))) ; not bol---simply back 1 ch
     (save-excursion
       (viper-forward-char-carefully val)
       (setq end-del-pos (point)))
@@ -4366,7 +4366,7 @@ and regexp replace."
          ((viper= char ?,) (viper-cycle-through-mark-ring))
          ((viper= char ?^) (push-mark viper-saved-mark t t))
          ((viper= char ?D) (mark-defun))
-         (t (error "Viper bell"))
+         (t (user-error viper-ViperBell))
          )))
 
 ;; Algorithm: If first invocation of this command save mark on ring, goto
@@ -4465,7 +4465,7 @@ One can use \\=`\\=` and \\='\\=' to temporarily jump 1 step back."
                 (switch-to-buffer buff)
                 (goto-char viper-com-point)
                 (viper-change-state-to-vi)
-                (error "Viper bell")))))
+                (user-error viper-ViperBell)))))
        ((and (not skip-white) (viper= char ?`))
         (if com (viper-move-marker-locally 'viper-com-point (point)))
         (if (and (viper-same-line (point) viper-last-jump)
index 4496f1cf7d5b337b850111928ba716f6a990e211..f5090573c86b53da8b4f60985a4457915f2ac6db 100644 (file)
@@ -1240,7 +1240,7 @@ reversed."
                (read-string "[Hit return to confirm] ")
              (quit
               (save-excursion (kill-buffer " *delete text*"))
-              (error "Viper bell")))
+              (user-error viper-ViperBell)))
            (save-excursion (kill-buffer " *delete text*")))
        (if ex-buffer
            (cond ((viper-valid-register ex-buffer '(Letter))
index 0ad9a7a373c751b7e5f891c072e24288059f6ac9..5a80804e7570eb56456ae137ce670e42d8a3dd4a 100644 (file)
@@ -268,6 +268,7 @@ that deletes a file.")
 (defconst viper-BadAddress "Ill-formed address"   "")
 (defconst viper-FirstAddrExceedsSecond "First address exceeds second"   "")
 (defconst viper-NoFileSpecified "No file specified"   "")
+(defconst viper-ViperBell "Viper bell"   "")
 
 ;; Is t until viper-mode executes for the very first time.
 ;; Prevents recursive descend into startup messages.