[libvirt] Emacs tip for easily adding Reviewed-by tags & friends

It is nice that git has the short-hand for adding Signed-off-by, but adding other tags during reviews is kind of tedious and long winded. eg "ACK" is much shorter than typing "Reviewed-by: ...blah blah blah.." Good editors have a way to setup macros though, and so I thought I'd share the emacs approach to making life easy again... In my $HOME/.emacs.d/abbrev_defs file I have this: (define-abbrev-table 'global-abbrev-table '( ("8rev" "Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8ack" "Acked-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8test" "Tested-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8sob" "Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) )) Now, if I type the "8rev" [1] and then hit space-bar or enter, emacs expands it to the full "Reviewed-by: ....blah blah blah..." line. This makes adding the full tags just as quick & easy as it was to type a traditional "ACK". Anyone have an equivalent tip for Vim ? Perhaps we could add them to the hacking file. Regards, Daniel [1] Why the leading "8" you might ask ? I've no idea. I just got this tip from QEMU developers - guess you just want some character seq that you're unlikely to want to type for real, to avoid accidental expansions. -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Thu, Mar 15, 2018 at 11:36:28AM +0000, Daniel P. Berrangé wrote:
It is nice that git has the short-hand for adding Signed-off-by, but adding other tags during reviews is kind of tedious and long winded. eg "ACK" is much shorter than typing "Reviewed-by: ...blah blah blah.."
Good editors have a way to setup macros though, and so I thought I'd share the emacs approach to making life easy again...
In my $HOME/.emacs.d/abbrev_defs file I have this:
(define-abbrev-table 'global-abbrev-table '( ("8rev" "Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8ack" "Acked-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8test" "Tested-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8sob" "Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ))
Now, if I type the "8rev" [1] and then hit space-bar or enter, emacs expands it to the full "Reviewed-by: ....blah blah blah..." line. This makes adding the full tags just as quick & easy as it was to type a traditional "ACK".
Anyone have an equivalent tip for Vim ?
I'm using the following plugin for Vim which I tuned just a tiny bit so that I could write even less :P. https://github.com/vim-scripts/git_patch_tags.vim Erik

On Thu, Mar 15, 2018 at 01:34:31PM +0100, Erik Skultety wrote:
On Thu, Mar 15, 2018 at 11:36:28AM +0000, Daniel P. Berrangé wrote:
It is nice that git has the short-hand for adding Signed-off-by, but adding other tags during reviews is kind of tedious and long winded. eg "ACK" is much shorter than typing "Reviewed-by: ...blah blah blah.."
Good editors have a way to setup macros though, and so I thought I'd share the emacs approach to making life easy again...
In my $HOME/.emacs.d/abbrev_defs file I have this:
(define-abbrev-table 'global-abbrev-table '( ("8rev" "Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8ack" "Acked-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8test" "Tested-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8sob" "Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ))
Now, if I type the "8rev" [1] and then hit space-bar or enter, emacs expands it to the full "Reviewed-by: ....blah blah blah..." line. This makes adding the full tags just as quick & easy as it was to type a traditional "ACK".
Anyone have an equivalent tip for Vim ?
I'm using the following plugin for Vim which I tuned just a tiny bit so that I could write even less :P.
What does it mean when it says "<Leader>" in that README. Is that a name referring to a magic key sequence, or literal text to type ? Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Thu, 2018-03-15 at 12:38 +0000, Daniel P. Berrangé wrote:
On Thu, Mar 15, 2018 at 01:34:31PM +0100, Erik Skultety wrote:
On Thu, Mar 15, 2018 at 11:36:28AM +0000, Daniel P. Berrangé wrote:
It is nice that git has the short-hand for adding Signed-off-by, but adding other tags during reviews is kind of tedious and long winded. eg "ACK" is much shorter than typing "Reviewed-by: ...blah blah blah.."
Good editors have a way to setup macros though, and so I thought I'd share the emacs approach to making life easy again...
In my $HOME/.emacs.d/abbrev_defs file I have this:
(define-abbrev-table 'global-abbrev-table '( ("8rev" "Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8ack" "Acked-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8test" "Tested-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8sob" "Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ))
Now, if I type the "8rev" [1] and then hit space-bar or enter, emacs expands it to the full "Reviewed-by: ....blah blah blah..." line. This makes adding the full tags just as quick & easy as it was to type a traditional "ACK".
Anyone have an equivalent tip for Vim ?
I'm using the following plugin for Vim which I tuned just a tiny bit so that I could write even less :P.
What does it mean when it says "<Leader>" in that README. Is that a name referring to a magic key sequence, or literal text to type ?
the leader is a key used at the beginning of some commands. It's referred as <Leader> in all vim docs since it can be changed by the user with mapleader command. By default the leader is '\' -- Cedric

On Thu, Mar 15, 2018 at 12:38:26PM +0000, Daniel P. Berrangé wrote:
On Thu, Mar 15, 2018 at 01:34:31PM +0100, Erik Skultety wrote:
On Thu, Mar 15, 2018 at 11:36:28AM +0000, Daniel P. Berrangé wrote:
It is nice that git has the short-hand for adding Signed-off-by, but adding other tags during reviews is kind of tedious and long winded. eg "ACK" is much shorter than typing "Reviewed-by: ...blah blah blah.."
Good editors have a way to setup macros though, and so I thought I'd share the emacs approach to making life easy again...
In my $HOME/.emacs.d/abbrev_defs file I have this:
(define-abbrev-table 'global-abbrev-table '( ("8rev" "Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8ack" "Acked-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8test" "Tested-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8sob" "Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ))
Now, if I type the "8rev" [1] and then hit space-bar or enter, emacs expands it to the full "Reviewed-by: ....blah blah blah..." line. This makes adding the full tags just as quick & easy as it was to type a traditional "ACK".
Anyone have an equivalent tip for Vim ?
I'm using the following plugin for Vim which I tuned just a tiny bit so that I could write even less :P.
What does it mean when it says "<Leader>" in that README. Is that a name referring to a magic key sequence, or literal text to type ?
<Leader> is a mod key basically, something like Win key in tiling WMs, I'm not sure whether in Vim's case it can be a key sequence, but you can configure it by having this in your .vimrc: let mapleader="," PS: jdenemar says the default <Leader> maps to '\' Erik

On Thu, Mar 15, 2018 at 11:36:28AM +0000, Daniel P. Berrangé wrote:
It is nice that git has the short-hand for adding Signed-off-by, but adding other tags during reviews is kind of tedious and long winded. eg "ACK" is much shorter than typing "Reviewed-by: ...blah blah blah.."
Good editors have a way to setup macros though, and so I thought I'd share the emacs approach to making life easy again...
In my $HOME/.emacs.d/abbrev_defs file I have this:
(define-abbrev-table 'global-abbrev-table '( ("8rev" "Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8ack" "Acked-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8test" "Tested-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8sob" "Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ))
Now, if I type the "8rev" [1] and then hit space-bar or enter, emacs expands it to the full "Reviewed-by: ....blah blah blah..." line. This makes adding the full tags just as quick & easy as it was to type a traditional "ACK".
Anyone have an equivalent tip for Vim ?
Perhaps we could add them to the hacking file.
Since we're sharing O:-) I had a script that extracted the mail from the 'From' mail header, so that you can reply from any address and don't need to change it. It also jumps to a newline in case you are not in start of the line. It'd be trivial to modify for arbitrary tags, of course. #+begin_src emacs-lisp (defun npx/message-get-from () "Get the address from the 'From' field of the current message" (save-excursion (goto-char (point-min)) (let ((beg (search-forward "From: ")) (end (line-end-position))) (buffer-substring-no-properties beg end)))) (defun npx/insert-tag-reviewed-by () "Inserts 'Reviewed-by: Real Name <email>' in the current position in buffer" (interactive) (let ((from (npx/message-get-from))) (when (not (equalp (point) (line-beginning-position))) (move-end-of-line nil) (newline 2)) (insert "Reviewed-by: " from) (newline))) (global-set-key (kbd "C-c r") 'npx/insert-tag-reviewed-by) #+end_src HTH, Martin
Regards, Daniel
[1] Why the leading "8" you might ask ? I've no idea. I just got this tip from QEMU developers - guess you just want some character seq that you're unlikely to want to type for real, to avoid accidental expansions. -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Daniel P. Berrangé <berrange@redhat.com> [2018-03-15, 11:36AM +0000]:
It is nice that git has the short-hand for adding Signed-off-by, but adding other tags during reviews is kind of tedious and long winded. eg "ACK" is much shorter than typing "Reviewed-by: ...blah blah blah.."
Good editors have a way to setup macros though, and so I thought I'd share the emacs approach to making life easy again...
In my $HOME/.emacs.d/abbrev_defs file I have this:
(define-abbrev-table 'global-abbrev-table '( ("8rev" "Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8ack" "Acked-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8test" "Tested-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ("8sob" "Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>" nil 1) ))
Now, if I type the "8rev" [1] and then hit space-bar or enter, emacs expands it to the full "Reviewed-by: ....blah blah blah..." line. This makes adding the full tags just as quick & easy as it was to type a traditional "ACK".
Anyone have an equivalent tip for Vim ?
Yes: iabbrev ackby Acked-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> iabbrev repby Reported-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> iabbrev revby Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> iabbrev sigby Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> iabbrev suggby Suggested-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> iabbrev testby Tested-by: Bjoern Walk <bwalk@linux.vnet.ibm.com> Should work identical to the emacs version. -- IBM Systems Linux on Z & Virtualization Development ------------------------------------------------------------------------ IBM Deutschland Research & Development GmbH Schönaicher Str. 220, 71032 Böblingen Phone: +49 7031 16 1819 ------------------------------------------------------------------------ Vorsitzende des Aufsichtsrats: Martina Koederitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
participants (5)
-
Bjoern Walk
-
Cedric Bosdonnat
-
Daniel P. Berrangé
-
Erik Skultety
-
Martin Kletzander