Add "Writing Better Elisp Docstrings" section

This commit is contained in:
Gerard Vermeulen 2024-04-19 11:40:48 +02:00
parent 9d7269a5c6
commit 1aeb7f9a11

View File

@ -5685,6 +5685,46 @@ byte code:
13 return
#+end_src
*** [[http://yummymelon.com/devnull/writing-better-elisp-docstrings.html][Writing Better Elisp Docstrings]]
:PROPERTIES:
:CUSTOM_ID: sec:describe-function-at-point
:END:
#+caption[Describe Elisp function at point]:
#+caption: Describe Elisp function at point.
#+name: lst:describe-function-at-point
#+begin_src emacs-lisp -n :results silent
;; Stolen from Charles Choi:
;; http://yummymelon.com/devnull/writing-better-elisp-docstrings.html
;; GAV: Org changes the semantics of calling `beginning-of-defun'.
(defun describe-function-at-point ()
"Call `describe-function' on the Elisp function at point.
Switch temporarily from `org-mode' to `text-mode', since `org-mode'
changes the semantics of calling `beginning-of-defun'."
(interactive)
(let ((mode major-mode))
(when (eq major-mode 'org-mode)
(text-mode))
(save-excursion
(beginning-of-defun)
(forward-char)
(forward-sexp 2)
(let ((end-point (point)))
(backward-sexp)
(let* ((fn-name (buffer-substring (point) end-point))
(interned (intern-soft fn-name)))
(if interned
(describe-function interned)
(message "Can't find function at point")))))
(when (eq mode 'org-mode)
(org-mode))))
(with-eval-after-load 'org-mode
(keymap-set org-mode-map "C-c d" #'describe-function-at-point))
(with-eval-after-load 'emacs-lisp-mode
(keymap-set emacs-lisp-mode-map "C-c d" #'describe-function-at-point))
#+end_src
** [[https://go.dev/][Go Programming]]
:PROPERTIES:
:CUSTOM_ID: sec:go-programming