0

I like using the Hyperbole implicit buttons as a very easy way to take actions by just doing M-RET on some text -- for example, I want to jump straight to the org-mode agenda for the day, so I put {C-c a a} in my buffer, and just hit M-RET there.

But...Hyperbole is weird. I've just never understood it. It does strange things when initializing (to keybindings; to opening buffers named BLANK) when initializing, and it just doesn't click for me. Since the only Hyperbole thing I want are those { } and < > buttons, I want to replace them and stop using Hyperbole, since I use so little of it, and so much of org-mode's functionality.

How can I do that?

2 Answers 2

1

The answer is to use elisp: org-mode links more, and combining them with named keyboard macros gives us this solution:

For example, starting the org agenda for the current day: I want to do the same thing that C-c a a does. Hyperbole's implicit buttons let me just do M-RET on {C-c a a}. We can do the same thing in org:

  1. Record a keyboard macro that does what you want. Or...don't, and just take your existing Hyperbole thing and copy the relevant string. Or use the strategy below with funcall and kmacro.
  2. Name the macro: name-last-kbd-macro. Call that my-start-org-agenda.
  3. Insert the macro with insert-kbd-macro to give it an alias that the elisp: link can use. That gives me:
(defalias 'start-org-agenda
  (kmacro "C-c a a"))
  1. Make elisp call that: in your org-mode buffer, just put in elisp:start-org-agenda or [[elisp:start-org-agenda][run org agenda!]].

Now you follow the org mode link as usual, and it does the same thing.

You may consider marking that as safe to call or otherwise making org not pester you about evaluating that lisp.

That lets me replace almost all of my Hyperbole use. And for slightly more complex bits, you can write a function to "parametrize" your call: do, say,

(defun start-org-agenda-and-send-useless-message (msg)
   (start-org-agenda)
   (message "You said '%s'." msg))

and make your link on: [[elisp:(start-org-agenda-and-send-useless-message "from an elisp link")][hello]].

If you want to parameterize the actual keyboard macro, it seems you can use funcall: continuing my silly example with the org-mode agenda, say you want a function that will launch various flavors of the agenda via C-c a TYPE:

(defun do-some-agenda-command (cmd)
  "Launch the org agenda with command `cmd'."
  (interactive)
  (let ((the-macro-string (format "C-c a %s" cmd)))
    (funcall (kmacro the-macro-string))))

Then replace Hyperbole things like {C-c a a} and {C-c a t} with elisp:(do-some-agenda command "a") and elisp:(do-some-agenda-command "t").

1

You can create a new link type in Org that runs whatever function you'd like when you follow the link. Here for example I define a new kbd link type that lets you run keyboard macros just like Hyperbole's {} key series notation:

(org-link-set-parameters
 "kbd"
 :follow
 (lambda (kmacro arg)
   (kmacro-call-macro arg t nil (kbd kmacro))))

Now you can use links like: <kbd:C-c a a> (or [[kbd:C-c a a]] if you prefer that link notation). And just in case let me mention that Org links are not limited to Org buffers! You can use the command org-open-at-point-global to open any Org link in any buffer at all.

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.