unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Add Viper bell to debug-ignored-errors
@ 2019-03-09 13:36 Christopher Wellons
  2019-03-09 16:53 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Christopher Wellons @ 2019-03-09 13:36 UTC (permalink / raw)
  To: emacs-devel

Using Viper and toggle-debug-on-error at the same time is irritating
because the debugger is activated on each "Viper bell" signal. This is
solved by adding the signal to debug-ignored-errors. Since Viper's other
common error messages are given a defconst, this patch replaces all
instances of "Viper bell" with a new defconst, viper-ViperBell, and that
defconst is also used for debug-ignored-errors.

diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index f041f25ae9..2784fe81c0 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -1124,7 +1124,7 @@ viper-prefix-arg-com
 	  ;; it is an error.
 	  (progn
 	    ;; new com is (CHAR . OLDCOM)
-	    (if (viper-memq-char char '(?# ?\")) (error "Viper bell"))
+	    (if (viper-memq-char char '(?# ?\")) (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 @@ viper-prefix-arg-com
 	       (let ((reg (read-char)))
 		 (if (viper-valid-register reg)
 		     (setq viper-use-register reg)
-		   (error "Viper bell"))
+		   (error viper-ViperBell))
 		 (setq char (read-char))))
 	      (t
 	       (setq com char)
@@ -1165,7 +1165,7 @@ viper-prefix-arg-com
 	      (viper-regsuffix-command-p char)
 	      (viper= char ?!) ; bang command
 	      (viper= char ?g) ; the gg command (like G0)
-	      (error "Viper bell"))
+	      (error viper-ViperBell))
 	  (setq cmd-to-exec-at-end
 		(viper-exec-form-in-vi
 		 `(key-binding (char-to-string ,char)))))
@@ -1199,7 +1199,7 @@ viper-prefix-arg-com
 	 ((equal com '(?= . ?=)) (viper-line (cons value ?=)))
 	 ;; gg  acts as G0
 	 ((equal (car com) ?g)   (viper-goto-line 0))
-	 (t (error "Viper bell")))))
+	 (t (error viper-ViperBell)))))
 
     (if cmd-to-exec-at-end
 	(progn
@@ -2609,9 +2609,9 @@ viper-forward-char
 	  ;; 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)) (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) (error viper-ViperBell))))
       (forward-char val)
       (if com (viper-execute-com 'viper-forward-char val com)))))
 
@@ -2626,7 +2626,7 @@ viper-backward-char
     (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) (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 @@ viper-goto-col
     (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)) (error viper-ViperBell)))
     ))
 
 
@@ -3084,7 +3084,7 @@ viper-goto-line
 ;; 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) (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 @@ viper-paren-match
 	     (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 (error viper-ViperBell))))))
 
 (defun viper-toggle-parse-sexp-ignore-comments ()
   (interactive)
@@ -4001,7 +4001,7 @@ viper-put-back
 	    (let ((reg viper-use-register))
 	      (setq viper-use-register nil)
 	      (error viper-EmptyRegister reg))
-	  (error "Viper bell")))
+	  (error viper-ViperBell)))
     (setq viper-use-register nil)
     (if (viper-end-with-a-newline-p text)
 	(progn
@@ -4051,7 +4051,7 @@ viper-Put-back
 	    (let ((reg viper-use-register))
 	      (setq viper-use-register nil)
 	      (error viper-EmptyRegister reg))
-	  (error "Viper bell")))
+	  (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 @@ viper-delete-char
 	     (> 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) (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 @@ viper-mark-point
 	  ((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 (error viper-ViperBell))
 	  )))
 
 ;; Algorithm: If first invocation of this command save mark on ring, goto
@@ -4465,7 +4465,7 @@ viper-goto-mark-subr
 		 (switch-to-buffer buff)
 		 (goto-char viper-com-point)
 		 (viper-change-state-to-vi)
-		 (error "Viper bell")))))
+		 (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)
diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el
index 4496f1cf7d..28d8e35737 100644
--- a/lisp/emulation/viper-ex.el
+++ b/lisp/emulation/viper-ex.el
@@ -1240,7 +1240,7 @@ ex-delete
 		(read-string "[Hit return to confirm] ")
 	      (quit
 	       (save-excursion (kill-buffer " *delete text*"))
-	       (error "Viper bell")))
+	       (error viper-ViperBell)))
 	    (save-excursion (kill-buffer " *delete text*")))
 	(if ex-buffer
 	    (cond ((viper-valid-register ex-buffer '(Letter))
diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el
index 0ad9a7a373..91ffc7b48e 100644
--- a/lisp/emulation/viper-init.el
+++ b/lisp/emulation/viper-init.el
@@ -268,6 +268,10 @@ viper-InvalidViCommand
 (defconst viper-BadAddress "Ill-formed address"   "")
 (defconst viper-FirstAddrExceedsSecond "First address exceeds second"   "")
 (defconst viper-NoFileSpecified "No file specified"   "")
+(defconst viper-ViperBell "Viper bell"   "")
+
+(add-to-list 'debug-ignored-errors
+             (concat "^" (regexp-quote viper-ViperBell) "$"))
 
 ;; Is t until viper-mode executes for the very first time.
 ;; Prevents recursive descend into startup messages.



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add Viper bell to debug-ignored-errors
  2019-03-09 13:36 [PATCH] Add Viper bell to debug-ignored-errors Christopher Wellons
@ 2019-03-09 16:53 ` Stefan Monnier
  2019-03-09 19:55   ` Christopher Wellons
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2019-03-09 16:53 UTC (permalink / raw)
  To: emacs-devel

> Using Viper and toggle-debug-on-error at the same time is irritating
> because the debugger is activated on each "Viper bell" signal. This is
> solved by adding the signal to debug-ignored-errors.

Good catch, thanks.

Nowadays these kinds of problems are solved by using `user-error`
instead of `error`.  This saves you the trouble of messing with
debug-ignored-errors.

Can you provide an updated patch using that?

Also, while this is sufficiently trivial not to require copyright
paperwork, it gets you closer to this point so it might be a good time
to start the process (IIRC you also have some packages that we could
include in GNU ELPA).  For that, please fill the form below and send it
as instructed to the FSF so they can send you the relevant paperwork
to sign.


        Stefan


Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.

Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES

[What is the name of the program or package you're contributing to?]
Emacs

[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]


[Do you have an employer who might have a basis to claim to own
your changes?  Do you attend a school which might make such a claim?]


[For the copyright registration, what country are you a citizen of?]


[What year were you born?]


[Please write your email address here.]


[Please write your postal address here.]





[Which files have you changed so far, and which new files have you written
so far?]





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add Viper bell to debug-ignored-errors
  2019-03-09 16:53 ` Stefan Monnier
@ 2019-03-09 19:55   ` Christopher Wellons
  2019-03-09 20:50     ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Christopher Wellons @ 2019-03-09 19:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> Nowadays these kinds of problems are solved by using `user-error`
> instead of `error`.

Oh, duh, that makes a lot more sense. Here's a patch with user-error
instead.

diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index f041f25ae9..f52ce72a6d 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -1124,7 +1124,7 @@ viper-prefix-arg-com
 	  ;; 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 @@ viper-prefix-arg-com
 	       (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 @@ viper-prefix-arg-com
 	      (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 @@ viper-prefix-arg-com
 	 ((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 @@ viper-forward-char
 	  ;; 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 @@ viper-backward-char
     (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 @@ viper-goto-col
     (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 @@ viper-goto-line
 ;; 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 @@ viper-paren-match
 	     (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 @@ viper-put-back
 	    (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 @@ viper-Put-back
 	    (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 @@ viper-delete-char
 	     (> 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 @@ viper-mark-point
 	  ((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 @@ viper-goto-mark-subr
 		 (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)
diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el
index 4496f1cf7d..f5090573c8 100644
--- a/lisp/emulation/viper-ex.el
+++ b/lisp/emulation/viper-ex.el
@@ -1240,7 +1240,7 @@ ex-delete
 		(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))
diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el
index 0ad9a7a373..5a80804e75 100644
--- a/lisp/emulation/viper-init.el
+++ b/lisp/emulation/viper-init.el
@@ -268,6 +268,7 @@ viper-InvalidViCommand
 (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.



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add Viper bell to debug-ignored-errors
  2019-03-09 19:55   ` Christopher Wellons
@ 2019-03-09 20:50     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2019-03-09 20:50 UTC (permalink / raw)
  To: Christopher Wellons; +Cc: emacs-devel

> Oh, duh, that makes a lot more sense. Here's a patch with user-error
> instead.

Thanks, pushed,


        Stefan



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-09 20:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-09 13:36 [PATCH] Add Viper bell to debug-ignored-errors Christopher Wellons
2019-03-09 16:53 ` Stefan Monnier
2019-03-09 19:55   ` Christopher Wellons
2019-03-09 20:50     ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).