0

In calc, t [ jumps to the beginning of the trail. But in a regular buffer, M-< jumps to the beginning. I'd like t < to do what t [ does now.

How can I do that in a use-package :bind declaration? If I do

    (:map calc-mode-map
          ("t<" . calc-trail-first)
          ("t>" . calc-trail-last)

I get

Error (use-package): casual-calc/:catch: Key sequence t < starts with non-prefix key t"

How can I do this remapping?

1
  • Only one question per post, please.
    – Drew
    Commented Aug 2 at 16:28

1 Answer 1

0

The root cause here seems to be related to the funky way calc is loading its keybindings.

If I start emacs with no customization of calc (or casual-calc, which I'm also trying to use), then do M-x calc, and then do C-h k t to see about the t key in calc, I get this!

t runs the command calc-missing-key (found in calc-mode-map), which is
an autoloaded interactive Lisp function in ‘calc-misc.el’.

It is bound to C-k, C-w, C-M-w, M-k and M-w, and many ordinary text
characters.

(calc-missing-key N)

This is a placeholder for a command which needs to be loaded from calc-ext.
When this key is used, calc-ext (the Calculator extensions module) will be
loaded and the keystroke automatically re-typed.

If I hit t in calc, then run the above declaration, it works.

If I try that declaration before doing t in calc, it doesn't work -- it looks like that prefix doesn't even get defined until you do t in calc.

Since it seems that the t prefix keymap isn't defined until the calc-ext package gets loaded, the solution seems to be to use that:

(use-package calc-ext
  :defer t
  :bind (:map calc-mode-map
              ("t<" . calc-trail-first)
              ("t>" . calc-trail-last)
              ("t[" . calc-trail-scroll-left)
              ("t]" . calc-trail-scroll-right)))
2
  • Weird: the above works on Linux (Ubuntu 24.04); but now trying this on a Windows machine, it doesn't. I need to do :demand t to get the calc-ext package to load so that the prefix map gets defined. I haven't dug in to see if there's something different about my configuration, or if it's a version thing, or a Windows/Linux thing, or what. But for anyone who finds the above doesn't work, trying :demand t to get it to load right away seems to be an option.
    – Dan Drake
    Commented Aug 5 at 12:43
  • :defer is implied by :bind according to the doc. Since you need it loaded, :demand is the right way (and I was mistaken before in my - now deleted - answer).
    – NickD
    Commented Aug 5 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.