6

I see this elisp code (Bernt Hansen):

(defun bh/hide-other ()
  (interactive)
  (save-excursion
    (org-back-to-heading 'invisible-ok)
    (hide-other)
    (org-cycle)
    (org-cycle)
    (org-cycle)))

and I wonder if the bh/hide-other name with the forward slash means something special. I'm guessing not. But I need clarification that this isn't some module or namespace rocket science.

  • 4
    It is common for people to user their own name initials when writing a custom function -- e.g., bh/. Many people dislike forward slash in functions and variables and prefer a dash instead. The forward slash in the function name does not mean anything special -- it could be anything -- e.g., a dash, a forward slash, the letter z, the letter a, etc. M-x describe-function RET hide-other RET -- "This function is obsolete since 25.1; use outline-hide-other instead. Hide everything except current body and parent and top-level headings." – lawlist Nov 12 '15 at 19:46
  • / is a symbol-constituent character in Emacs-Lisp mode. That is, it is an ordinary character for symbol names. – Drew Nov 12 '15 at 21:12
8

There's no name space in Emacs lisp, so people use various prefixes to avoid name clash. Section D.1 of Emacs lisp reference manual recommends using a short prefix followed by one or two hyphen(s):

• You should choose a short word to distinguish your program from other Lisp programs. The names of all global symbols in your program, that is the names of variables, constants, and functions, should begin with that chosen prefix. Separate the prefix from the rest of the name with a hyphen, ‘-’. This practice helps avoid name conflicts, since all global variables in Emacs Lisp share the same name space, and all functions share another name space(1). Use two hyphens to separate prefix and name if the symbol is not meant to be used by other packages.

See this question about why elisp does not have namespaces.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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