Add my better pretty print s-expression

This commit is contained in:
Howard Abrams 2022-05-11 10:53:20 -07:00
parent ffd8925320
commit b7b5d1aada

View file

@ -274,6 +274,24 @@ And a keybinding:
(ha-prog-leader "c" '("comment line" . ha-comment-line)) (ha-prog-leader "c" '("comment line" . ha-comment-line))
#+END_SRC #+END_SRC
** Evaluation ** Evaluation
While I like [[help:eval-print-last-sexp][eval-print-last-sexp]], I would like a bit of formatting in order to /keep the results/ in the file.
#+BEGIN_SRC emacs-lisp
(defun ha-eval-print-last-sexp (&optional internal-arg)
"Evaluate the expression located before the point.
The results are inserted back into the buffer at the end
of the line after a comment."
(interactive)
(save-excursion
(eval-print-last-sexp internal-arg))
(end-of-line)
(insert " ")
(insert comment-start)
(insert "⟹ ")
(dotimes (i 2)
(next-line)
(join-line)))
#+END_SRC
Typical keybindings for all programming modes: Typical keybindings for all programming modes:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(ha-prog-leader (ha-prog-leader
@ -283,25 +301,24 @@ Typical keybindings for all programming modes:
"e f" '("function" . eval-defun) "e f" '("function" . eval-defun)
"e r" '("region" . eval-region) "e r" '("region" . eval-region)
"e e" '("last s-exp" . eval-last-sexp) "e e" '("last s-exp" . eval-last-sexp)
"e p" '("print s-exp" . eval-print-last-sexp)) "e p" '("print s-exp" . ha-eval-print-last-sexp))
#+END_SRC #+END_SRC
** Ligatures ** Ligatures
The idea of using math symbols for a programming languages keywords is /cute/, but can be confusing, so I use it sparingly: The idea of using math symbols for a programming languages keywords is /cute/, but can be confusing, so I use it sparingly:
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(add-hook (defun ha-prettyify-prog ()
'prog-mode-hook "Extends the `prettify-symbols-alist' for programming."
(lambda () (mapc (lambda (pair) (push pair prettify-symbols-aist))
(mapc (lambda (pair) (push pair prettify-symbols-alist))
'(("lambda" . "𝝀") '(("lambda" . "𝝀")
(">=" . "≥") (">=" . "≥")
("<=" . "≤") ("<=" . "≤")
("!=" . "≠"))))) ("!=" . "≠")))
(prettify-symbols-mode))
(add-hook 'prog-mode-hook 'ha-prettify-prog)
#+END_SRC #+END_SRC
The rest of the ligature system in Doom is nice.
** Task Runner ** Task Runner
I've replaced my home-grown compilation list code with a more versatile [[https://github.com/emacs-taskrunner/emacs-taskrunner][Taskrunner project]]. I've replaced my home-grown compilation list code with a more versatile [[https://github.com/emacs-taskrunner/emacs-taskrunner][Taskrunner project]].
#+BEGIN_SRC emacs-lisp :tangle no #+BEGIN_SRC emacs-lisp :tangle no