Subject: Re: bug#33570: 26.1.90; Weirdness with prefix arg and kmacro-end-and-call-macro

From: Live System User <[email-masked]>
Date: Sun, 02 Dec 2018 06:28:41 -0500

Eli Zaretskii <[email-masked]> writes:

>> From: Live System User <[email-masked]>
>> Date: Sat, 01 Dec 2018 21:28:47 -0500
>> 
>> Macro:
>> 
>> 5*;			;; self-insert-command
>> C-a			;; move-beginning-of-line
>> C-n			;; next-line
>> 
>> 
>>         What I was trying to do was to comment out some lines in
>>         an elisp file by adding  semi-colons, going back to the
>>         begining of the line and then positoning to the next line.
>> 
>>         I tested the macro via "C-x e" (kmacro-end-and-call-macro)
>>         to make sure it gave the results that I wanted which it did.
>>         So I then added a prefix argument:
>> 
>>            C-u 20 C-x e
>>         and saw this:
>> 
>> ;;;;;(setq magit-blame-heading-format "%-20a %C %s %H")
>> ;;;;;
>> ;;;;;(setq magit-branch-read-upstream-first nil)
>> ;;;;;(setq magit-branch-arguments nil)
>> ;;;;;
>> ;;;;;;; FIXME: ADD https://github.com/wuliuxiansheng/Emacs_Configuration/blob/;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;master/lisp/init-vc.el
>> 
>>         It looks like the macro did not go to the next line but stayed
>>         on line 41 of a 51-line buffer.
>> 
>>         What happened?
>
> I don't know, since you didn't show the text before the change, and
> you only show 6 lines out of 20 that should have been changed.

  That's because the next lines remained the same:

(setq magit-diff-refine-hunk 'all) ; refine all hunks instead of just the
                                   ; selected one

   which you'll notice did NOT add the semi-colons to those 2 lines
   nor any subsequent lines.

   The original text starting from the point where rhe macro was
   called::

(setq magit-display-buffer-function
      #'magit-display-buffer-fullframe-status-v1)

(defadvice magit-status (around magit-fullscreen activate)
  (window-configuration-to-register :magit-fullscreen)
  ad-do-it
  (delete-other-windows))
(global-set-key "\C-c\g" 'magit-status)

(defun magit-quit-session ()
  "Restores the previous window configuration and kills the magit buffer"
  (interactive)
  (magit-mode-quit-window)
  (jump-to-register :magit-fullscreen))
;(define-key magit-status-mode-map (kbd "Q") 'magit-quit-session)

;; Show commit SHA in blame mode.
(setq magit-blame-heading-format "%-20a %C %s %H")

(setq magit-branch-read-upstream-first nil)
(setq magit-branch-arguments nil)

;; FIXME: ADD https://github.com/wuliuxiansheng/Emacs_Configuration/blob/master/lisp/init-vc.el
(setq magit-diff-refine-hunk 'all) ; refine all hunks instead of just the
                                   ; selected one

;; make diff chunks stand out a bit more:
;(set-face-background 'magit-diff-hunk-heading-highlight "#5d4d7a")

>
>>         Is there an issue with logical/visual lines and its
>         interection with "C-a" and/or "C-n" used in keyboard
>         macros?

C-n moves by visual lines by default, is that what you asked?

    Is the long line above ";; FIXME:..." (with the line continuation
    indicator) 1 visual line and also it's 2 logical ones?

    IIUC, this would mean that C-n would go to the (logical) line:

                r/lisp/init-vc.e;

     and not to the next (visual) line which starts with:
     
                (setq magit-diff-refine-hunk ...
                
    Thanks.