Subject: bug fix: viper-put-back and viper-Put-back do not set viper-d-com correctly
From: "Scott, Michael" <[email-masked]>
To: "[email-masked]" <[email-masked]>, "[email-masked]" <[email-masked]>
Date: Fri, 2 May 2025 20:28:17 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

To: [email-masked], [email-masked]
Subject: Viper version is 3.14.2 of July 4, 2013; viper-put-back and viper-Put-back do
not correctly set viper-d-com
From: mls <[email-masked]>

Congratulations! You may have unearthed a bug in Viper!
Please mail a concise, accurate summary of the problem to the address above.

In the code for viper-put-back and viper-Put-back, both in viper-cmd.el,
viper-use-register is reset to nil before calling viper-set-destructive-command.
It needs to happen after:

sigma> diff -c viper-cmd.el viper-cmd_fix.el
*** viper-cmd.el Fri May  2 16:19:41 2025
--- viper-cmd_fix.el Fri May  2 16:20:37 2025
***************
*** 3865,3871 ****
       (setq viper-use-register nil)
       (error viper-EmptyRegister reg))
   (user-error viper-ViperBell)))
-     (setq viper-use-register nil)
      (if (viper-end-with-a-newline-p text)
  (progn
   (end-of-line)
--- 3865,3870 ----
***************
*** 3877,3882 ****
--- 3876,3882 ----
      (set-marker (mark-marker) (point) (current-buffer))
      (viper-set-destructive-command
       (list 'viper-put-back val nil viper-use-register nil nil))
+     (setq viper-use-register nil)
      (setq sv-point (point))
      (viper-loop val (viper-yank text))
      (setq chars-inserted (abs (- (point) sv-point))
***************
*** 3915,3924 ****
       (setq viper-use-register nil)
       (error viper-EmptyRegister reg))
   (user-error viper-ViperBell)))
-     (setq viper-use-register nil)
      (if (viper-end-with-a-newline-p text) (beginning-of-line))
      (viper-set-destructive-command
       (list 'viper-Put-back val nil viper-use-register nil nil))
      (set-marker (mark-marker) (point) (current-buffer))
      (setq sv-point (point))
      (viper-loop val (viper-yank text))
--- 3915,3924 ----
       (setq viper-use-register nil)
       (error viper-EmptyRegister reg))
   (user-error viper-ViperBell)))
      (if (viper-end-with-a-newline-p text) (beginning-of-line))
      (viper-set-destructive-command
       (list 'viper-Put-back val nil viper-use-register nil nil))
+     (setq viper-use-register nil)
      (set-marker (mark-marker) (point) (current-buffer))
      (setq sv-point (point))
      (viper-loop val (viper-yank text))
sigma>

With this fix, a command like “xp or “xP will repeat correctly with the dot command.

-------------------------------------------------------------------

Emacs  : GNU Emacs 29.4 (build 1, aarch64-apple-darwin21.6.0, NS appkit-2113.60 Version 12.6.6 (Build 21G646))
 of 2024-08-02
Package: Viper version is 3.14.2 of July 4, 2013

current state:
==============
(setq
 viper-vi-minibuffer-minor-mode nil
 viper-insert-minibuffer-minor-mode nil
 viper-vi-intercept-minor-mode t
 viper-vi-local-user-minor-mode t
 viper-vi-kbd-minor-mode t
 viper-vi-global-user-minor-mode t
 viper-vi-state-modifier-minor-mode t
 viper-vi-diehard-minor-mode nil
 viper-vi-basic-minor-mode t
 viper-replace-minor-mode nil
 viper-insert-intercept-minor-mode nil
 viper-insert-local-user-minor-mode nil
 viper-insert-kbd-minor-mode nil
 viper-insert-global-user-minor-mode nil
 viper-insert-state-modifier-minor-mode nil
 viper-insert-diehard-minor-mode nil
 viper-insert-basic-minor-mode nil
 viper-emacs-intercept-minor-mode nil
 viper-emacs-local-user-minor-mode nil
 viper-emacs-kbd-minor-mode nil
 viper-emacs-global-user-minor-mode nil
 viper-emacs-state-modifier-minor-mode nil
 viper-automatic-iso-accents nil
 viper-special-input-method nil
 viper-want-emacs-keys-in-insert t
 viper-want-emacs-keys-in-vi t
 viper-keep-point-on-undo nil
 viper-no-multiple-ESC t
 viper-electric-mode nil
 viper-ESC-key "`"
 viper-want-ctl-h-help nil
 viper-ex-style-editing nil
 viper-delete-backwards-in-replace nil
 viper-vi-style-in-minibuffer t
 viper-vi-state-hook 'viper-restore-cursor-type
 viper-insert-state-hook '(turn-on-auto-fill viper-set-insert-cursor-type)
 viper-replace-state-hook 'viper-restore-cursor-type
 viper-emacs-state-hook 'viper-restore-cursor-type
 ex-cycle-other-window t
 ex-cycle-through-non-files nil
 viper-expert-level 5
 major-mode 'fundamental-mode
 window-system 'ns
 x-display-color-p t
 viper-frame-parameters '((tool-bar-position . top) (parent-id)
                          (explicit-name) (display . "scott.cs.rochester.edu")
                          (visibility . t) (icon-name) (window-id . "1")
                          (top . 25) (left . 1526)
                          (buried-buffer-list #<buffer *Completions*> #<buffer
                           *viper-ask-level*>)
                          (buffer-list #<buffer .viper> #<buffer
                           viper-cmd.el.gz> #<buffer viper-init.el.gz>
                           #<buffer *Backtrace*> #<buffer *Help*> #<buffer
                           *Buffer List*> #<buffer chap.tex> #<buffer
                           CDex.tex<04_semantics>> #<buffer
                           2025-05-01_Yuan_Yao> #<buffer attr_grammars.tex>
                           #<buffer main.tex> #<buffer *scratch*> #<buffer
                           2025-04-10_hbeadle> #<buffer response.txt> #<buffer
                           notes> #<buffer 2025-04-29_rdong3+sree> #<buffer
                           CDex.tex<03_names>> #<buffer notes.txt>)
                          (unsplittable) (modeline . t) (width . 80)
                          (height . 86) (name . "Emacs-arm64-11@sigma")
                          (last-focus-update . t)
                          (viper-vi-state-cursor-color . "firebrick")
                          (viper-saved-cursor-color-in-replace-mode .
                           "firebrick")
                          (environment) (font-parameter)
                          (cursor-color . "firebrick")
                          (background-mode . light) (display-type . color)
                          (scroll-bar-background) (scroll-bar-foreground)
                          (window-system . ns) (fullscreen) (alpha-background)
                          (alpha) (scroll-bar-height . 15)
                          (scroll-bar-width . 15) (cursor-type . box)
                          (auto-lower) (auto-raise) (icon-type) (title)
                          (buffer-predicate) (tool-bar-lines . 0)
                          (tab-bar-lines . 0) (menu-bar-lines . 0)
                          (no-accept-focus) (no-focus-on-map) (z-group)
                          (parent-frame) (ns-transparent-titlebar)
                          (ns-appearance) (undecorated) (no-special-glyphs)
                          (right-fringe . 8) (left-fringe . 8) (line-spacing)
                          (background-color . "alice blue")
                          (foreground-color . "Black")
                          (horizontal-scroll-bars)
                          (vertical-scroll-bars . right)
                          (bottom-divider-width . 0) (right-divider-width . 0)
                          (child-frame-border-width)
                          (internal-border-width . 2) (border-width . 0)
                          (font .
                           "-*-Monaco-regular-normal-normal-*-12-*-*-*-m-0-iso10646-1")
                          (fontsize . 0) (font-backend mac-ct)
                          (minibuffer . t))
 viper-minibuffer-vi-face [face unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified]
 viper-minibuffer-insert-face [face unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified]
 viper-minibuffer-emacs-face [face unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified unspecified]
 )
--text follows this line--

--
Michael L. Scott (he/him)
Arthur Gould Yates Professor of Engineering
Computer Science Department, University of Rochester
[email-masked]<mailto:[email-masked]>; 585-275-5671, 5478
http://www.cs.rochester.edu/u/scott/