0

I want to write a shorthand for a shorthanded autoloaded function in a package, like so:

;;; super-duper-long-package-name.el --- Provide a cool command -*- lexical-binding: t -*- ;; Version: 0.1.0 ;;; Code: (require 'someone-elses-super-duper-long-package-name) ;;;###autoload (defun sdlpn-cool-command () "Display a cool message." (interactive) (message (someone-elses-super-duper-long-package-name-cool-command))) (provide 'super-duper-long-package-name) ;; Local Variables: ;; read-symbol-shorthands: (("sdlpn-" . "super-duper-long-package-name-") ;; ("sesdlpn-" . "someone-elses-super-duper-long-package-name-")) ;; End: ;;; super-duper-long-package-name.el ends here 

But when the package is installed, and I try running the command, there are two problems:

  1. The command is still named sdlpn-cool-command.

  2. When I run the command using M-x sdlpn-cool-command RET, Emacs complains in a message:

    execute-extended-command: Autoloading file /home/super-duper-long-user-name/.emacs.d/elpa/super-duper-long-package-name-0.1.0/super-duper-long-package-name.elc failed to define function sdlpn-cool-command

How do you solve it?

1

1 Answer 1

0

Just name it super-duper-long-package-name-cool-command.

Shorthands are meant for your own code, either when you use your own package code or when you (require 'someone-elses-extremely-long-package-name) and need to write code using names defined in it, like so:

;;; super-duper-long-package-name.el --- Provide a cool command -*- lexical-binding: t -*- ;; Version: 0.1.1 ;;; Code: (require 'someone-elses-super-duper-long-package-name) ;;;###autoload (defun super-duper-long-package-name-cool-command () "Display a cool message." (interactive) (message (someone-elses-super-duper-long-package-name-cool-command))) (provide 'super-duper-long-package-name) ;; Local Variables: ;; read-symbol-shorthands: (("sdlpn-" . "super-duper-long-package-name-") ;; ("sesdlpn-" . "someone-elses-super-duper-long-package-name-")) ;; End: ;;; super-duper-long-package-name.el ends here 

someone-elses-extremely-long-package-name may be defined like so, and notice the shorthanded function sesdlpn-cool-command is not defined to be autoloaded, so using a shorthand is okay:

;;; someone-elses-super-duper-long-package-name.el --- Provide a cool string generating functions -*- lexical-binding: t -*- ;; Version: 0.2.3 ;;; Code: (defun sesdlpn-cool-command () "Return a cool string." "COOL!") (provide 'someone-elses-super-duper-long-package-name) ;; Local Variables: ;; read-symbol-shorthands: (("sesdlpn-" . "someone-elses-super-duper-long-package-name-")) ;; End: ;;; someone-elses-super-duper-long-package-name.el ends here 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.