0

Imagine you've got file with FirstName|LastName| like this :

John|toto|
Hanz|titi|

and want to put the first names at the end of the lines (just an stupid exemple). You may use Macro Recordind for that and type:

Arrow-down Home Ctrl-Space Ctrl-s | RET Arrow-left Ctrl-C End Ctrl-v

Under Linux, the execution of the macro rings the bell, hence doesn't work. But under Windows it works fine ! Isn't that a shame ? :)
If we look at the macro definitions, the results are just a very litlle bit different. Under Linux:

(fset 'makeMail2
      (lambda (&optional arg)
        "Keyboard macro."
        (interactive "p")
        (kmacro-exec-ring-item
          '([down home 67108896 19 124 return left 3 3 timeout end 22]
            0
            "%d")
          arg)))`

And under Windows :

(fset 'makeMail2Win
      (lambda (&optional arg)
        "Keyboard macro."
        (interactive "p")
        (kmacro-exec-ring-item
          '([down home 67108896 19 124 return left 3 timeout end 22]
            0
            "%d")
          arg)))

The only difference I see is left 3 3 versus left 3 under Windows.
Is this the cause of the fail ? Is this a bug or is it normal ? How can I make my macro work under Linux ?

NB: Linux Emacs version is 25, and Windows is 24...

Drew
  • 75,699
  • 9
  • 109
  • 225
jcm69
  • 111
  • 3
  • 2
    "Linux Emacs version is 25, and Windows is 24" seems like it would be more significant than the platform. Can you please test with the same version of [Emacs 25 on Windows](https://ftp.gnu.org/pub/gnu/emacs/windows/emacs-25/)?" – phils Mar 16 '19 at 23:58
  • 2
    Other observations: `3` is `C-c`, so `3 3` is `C-c C-c` which is a commonly-used key sequence in various Emacs modes and keymaps. You're obviously *expecting* `cua-mode` to be in effect, as you're trying to use `C-c` and `C-v` for copy and paste. Is that assumption actually correct in your Linux case? – phils Mar 17 '19 at 00:05
  • 1
    @phils I've just tested with Emacs25 on Windows and the results are the same. But I've realized yesterday that makeMail2Win was working fine on Linux ! So the problem comes from the definition of the macro on Linux. Guess what I did : I just modified makeMail2 by suppressing one of the two 3 and, bingo, it workes fine under Linux. Yes, I use cua-mode on both platforms. – jcm69 Mar 17 '19 at 17:35

1 Answers1

1

The answer is don't use cua-mode on Linux, it's OK if you are on windows (but not on wsl of course). It works fine when using M-w and C-y and the definition of the macro becomes:

(fset 'makeMailNoCua
   (lambda (&optional arg) 
   "Keyboard macro." 
   (interactive "p") 
   (kmacro-exec-ring-item 
      (quote ([down home 67108896 19 124 return left 134217847 end 25] 
      0 
      "%d"))
     arg)))

Many thanks to phils. Once the solution found, it's easier to find that the problem was known, see Cua-mode and keyboard macros and has a fix ;)

jcm69
  • 111
  • 3