Inserting footnotes via keyboard shortcuts

As I use footnotes quite often, I find inserting them from the menu: Insert –> Note –> Footnote a bit tedious. So, I wonder if it is possible to use a keyboard shortcut, say M-F6 (⌘-F6 on macOS), to accomplish that.

I have a vague understanding of how to modify simple keyboard behaviour in my-init-texmacs.scm but I do not know the name of the scheme function for calling Insert –> Note –> Footnote.

Here on this forum http://forum.texmacs.cn/t/how-to-make-hotkey-for-action-from-menu/319/4 @jeroen suggested using the built-in keyboard shortcut tool that would save changes made to ~/.TeXmacs/system/shortcuts.scm.

  • Where can I find and access this tool?

  • Is there a list or file that shows the internal commands behind menu items?

Any help and suggestions appreciated.

Cheers,
Tilda

Hi @Tilda, I never used the built-in keyboard shortcut tool (perhaps I did but if I did, only for a short time).
Here is what I do: I do a search on the TeXmacs GitHub repository using as search key the menu item name (in this case “footnote”), in the search results I select only the Scheme files and I go through them looking for the menu item.
For “footnote” I found in the file progs/generic/insert-menu.scm the list ("Footnote" (make 'footnote)) and by placing

(kbd-map ("A-e f" (make 'footnote)))

in my-init-texmacs.scm I obtained a shortcut for placing footnotes.

@jeroen uses ack for searching through the TeXmacs Scheme files on the local disk, perhaps you like that more than the GitHub search I do.

I never listed the files where the menu items are defined (using menu-bind I think), I don’t think a list written up by the developers exists and I am not aware of an automatic way for generating it (id est, one needs to write a program that does that :-)).
Listing them by hand takes a bit of patience and if the files where the menus are defined change gradually from release to release the list becomes outdated when there are new releases.

3 Likes

ack "Footnote" . when in the progs directory of the TeXmacs installation :slight_smile:

Dear @pireddag, thanks for your fast reply. Putting

(kbd-map (“M-F6” (make 'footnote)))

into my-init-texmacs.scm did the job. Simply pressing ⌘-F6 now automatically inserts a new footnote.

I will give ack a go, check the files in .../progs/generic/* and see what it can do better than grep or (g)awk :wink:

btw, what is the difference between putting (re)definitions in ~/.TeXmacs/progs/my-init-texmacs.scm and placing them in ~/.TeXmacs/system/shortcuts.scm? Does this have s.th. to do with the order of precedence?

Cheers,
Tilda

I do not know, I had not realized that ~/.TeXmacs/system/shortcuts.scm exists :slight_smile:
I think that TeXmacs writes automatically in some of those files (e.g. preferences.scm); perhaps it is where the keyboard shortcut tool puts “its” shortcuts??

Ah, the mysterious keyboard shortcut tool again. Is it accessible via menu? Maybe @jeroen would know,

I figured it out: Tools->Keyboard->Edit keyboard shortcuts. The shortcuts defined through the tool are saved in ~/.TeXmacs/system/shortcuts.scm, with a syntax different from the one you use in my-init-texmacs.scm.
It is possible that defining shortcuts in my-init-texmacs.scm is more flexible, I do not see how to apply a definition in one mode only using the tool and I do not find it sensible to edit the shortcuts save in shortcuts.scm to achieve that.

3 Likes

The shortcut tool seems rather broken. I can’t get it to remove shortcuts and it is very difficult to capture the correct key sequence. If you know how to use my-init-texmacs.scm, I would not use it.

2 Likes

Thanks to you both, @pireddag and @jeroen, for the effort and information. Then, let’s stick with the trusty ofd my-init-texmacs.scm.

1 Like

Maybe someone will find these keyboard shortcuts useful:

(delayed  
(lazy-keyboard-force)
  (kbd-map
    ("M-F6" (make 'footnote)) 
    ("A-f"  (make 'footnote))      ;; alt-f from trusty old wp5.x
    ("A-c"  (make 'cite))    
    ("A-d"  (make 'cite-detail))   ;; overrides ∂ on macOS
    ("A-h"  (make 'hlink))         ;; overrides ordfeminine    
;;  ("C-h"  (make 'hlink))         ;; overrides ??
	("C-p"  (make 'problem))
    ("C-s"  (make 'solution))      ;; overrides "strong"  
    ("C-t"  (make 'theorem))       ;; overrides ??
;;  ("C-q"  (make 'quote-env))     ;; overrides compose key
    ("C-y"  (make 'quote-env))     ;; overrides ?? 
    ("C-z"  (make 'quotation)) 
  )
)

btw, @pireddag, ack is a cool perl script.

Cheers,
Tilda

1 Like

I fixed 3 bugs of the shortcut tool yesterday night.

It is fantastic!

1 Like

Almost everyone in this tier has their corresponding texmacs macros. Overly many kbd shortcut will be a heavy mental burden, at least for me. If you want footnote, just press back-slash \, type footnote then hit enter.

1 Like