Hacker News new | ask | show | jobs
by klibertp 4012 days ago
> I wouldn't know how to discover on my own.

Go read the manual. I mean, I know it's not cool to read books, and manuals at that, but the Emacs Lisp and Emacs manuals (available in info format for viewing directly in Emacs, among other) are well written and there's a wealth of information there. Even relatively low-level stuff gets explained quite well. And also, try using the help system/apropos tool. It's great for finding functions and variables. Lastly, you can always issue "find-function" or "find-library" which will take you directly to the source code.

> With some trial and error, I could find out if `(setq cursor-color "White")` works.

Use iELM session for this (M-x ielm). You'll get Elisp REPL, where you can write expressions and it'll show you their values. In this case:

  ELISP> cursor-color
  *** Eval error ***  Symbol's value as variable is void: cursor-color
so, no.

> Or see if `set-blink-cursor-interval` exists.

In ielm:

  (symbol-function 'set-blink-cursor-interval) ;; (no, it doesn't)
Via help system: C-h a; then input the name.

> Or look up why `set-cursor-color` exists in the first place when surely it's more consistent to just modify a config variable.

Don't know why is is so, but you can possibly find some explanation in the source code. `set-cursor-color` is defined in /usr/local/share/emacs/25.0.50/lisp/frame.el.gz on my system on line 1223. You can get there with M-x find-function.

> Or find some best Emacs lisp practices online.

Does it really have to be online? There is a full book for this: "Writing GNU Emacs Extensions". It's old, but solid. [EDIT: and also https://www.gnu.org/software/emacs/manual/pdf/eintr.pdf]

> Or figure out why I could never get working my one attempt to write a custom function to scratch my own itch.

Sorry to break it to you, but if it's not working it's because you coded it wrong. All my defuns do work...

BTW, do you know that you can one-step Elisp code with a built-in debugger? Just find a defun, eval it via C-u C-M-x and you'll get breakpoint at the defun entry.