Emacs Info Expressions
susam.net
susam.net
https://blog.nawaz.org/posts/2023/Mar/creating-info-manuals-...
I'd also like to add that in ipython and jupyter, you can do `symbol?` and `symbol??` to get help and detailed help, respectively.
I also think I'm obliged to share this tip: you can write a function that copies a Markdown-style link [(info "Node")](https://gnu.org/...). ;-)
It has now been removed :)
> " " C-b C-y C-a C-SPC C-e M-( info C-a C-k C-/
Ohh emacs. lol
On the other hand, nobody bothers writing out the equivalent in VSCode or another conventional editor because it's so much worse:
"" <left> <Ctrl+V> <Ctrl+left> <hold shift> <Ctrl+right> <release shift> <Ctrl+C> <wrap-selection-in-parens-command(?)> info <Ctrl+left> <hold shift> <right> <release shift> <Ctrl+X> yypi(info "<esc>A")<esc>dd
in vim, which imo is roughly as ugly, but like others are saying, it's all muscle memory and thus doesn't break flow state.> Ohh emacs. lol
This may seem like a lot of work but at least for me this is all muscle memory, so I happen to type them without even realising what I am typing.
It is sort of like playing the piano. When you play your favourite song on the piano, you don’t think of the keys you are pressing. It is all muscle memory. You just let your brain and fingers do the work and your conscious being can simply enjoy the music. It’s like that with Emacs too!
Also, since this is Emacs we are talking about, of course we have a simpler alternative that involves only a couple of keystrokes: C-0 c. This is discussed in the next section of the post.
I saw it and said: ooh, what's that, looks intense? And then I actually looked at the first couple and went ooooh, type in double quotes, jump back and paste (C-a then C-y), select the whole thing (C-a C-SPC C-e), etc etc till the end. Except without really "saying anything" in my head, cos it's just muscle memory, you do it all the time, it's like walking.
C-0 c
to get the same result.
(info "(elisp) Hash Tables")
(info "(elisp) Cons Cells")
(info "(elisp) Vectors")
Then I asked myself how I can run it without going to the last parenthesis and then hitting C-x C-e, so I wrote a function: ;;;; eval expression at point in text / markdown
(defun ugt-eval-expression-at-point ()
"Evaluate the expression at the current point."
(interactive)
(save-excursion
(while (ignore-errors (backward-up-list) t)) ; Move to the beginning of the outermost sexp
(let ((end (point)))
(forward-sexp) ; Move to the end of this sexp
(eval-region end (point)))))
(global-set-key (kbd "C-s-e") 'ugt-eval-outermost-sexp-at-point)
So now I can be in between the parentheses and hit C-s-e (Control-Command-e), and it will be evaluated.I even embed search expressions in my documents:
(ugt-search "French Revolution")
So be able to just click those expressions, I created another function: ;;;; highlight s-expressions
(defun ugt-highlight-expressions ()
"Make expressions starting with '(' and ending with ')' highlighted."
(interactive)
(save-excursion
(goto-char (point-min))
(let ((expression-regex "\\((.*?)\\)"))
(while (re-search-forward expression-regex nil t)
(let* ((start (match-beginning 0))
(end (match-end 0))
(expression (match-string-no-properties 0)))
(let ((overlay (make-overlay start end)))
(overlay-put overlay 'face '(:foreground "#8FBFDC" :weight bold))
(overlay-put overlay 'help-echo (concat "Click to evaluate: " expression))
(overlay-put overlay 'mouse-face 'highlight)
(overlay-put overlay 'keymap (let ((map (make-sparse-keymap)))
(define-key map [mouse-1]
`(lambda ()
(interactive)
(let ((expr ,expression))
(eval (read expr))
(message "Evaluated expression: %s" expr))))
map))))))))
## EditEmacs just rocks!