Merge branch 'main' of apps.bram85.nl:bram/gists
This commit is contained in:
commit
3253ed5f6b
|
@ -1,3 +1,3 @@
|
|||
Gists referred from [[https://emacs.ch/@bram85][@bram85@emacs.ch]].
|
||||
|
||||
Unfortunately gitea has no gist support and there's no mature yet lightweight gist solution suitable for self-hosting, so resorting to this poor-man's setup of sharing gists with an audience.
|
||||
Unfortunately Forgejo has no gist support and there's no mature yet lightweight gist solution suitable for self-hosting, so resorting to this poor-man's setup of sharing gists with an audience.
|
||||
|
|
71
gists.org
71
gists.org
|
@ -300,6 +300,7 @@ My vertico-repeat setup.
|
|||
")")))
|
||||
")")))))
|
||||
,#+end_example
|
||||
#+end_src
|
||||
|
||||
* Define a lambda in a let expression
|
||||
|
||||
|
@ -314,6 +315,76 @@ My vertico-repeat setup.
|
|||
(f "This does not work."))
|
||||
#+end_src
|
||||
|
||||
* Use outline-minor-mode with eshell :emacs:eshell:
|
||||
|
||||
Found [[https://www.reddit.com/r/emacs/comments/e2u5n9/comment/f918t22/][a Reddit comment]] suggesting to assign the prompt regexp to the outline regexp. Here's the corresponding =use-package= syntax:
|
||||
|
||||
#+begin_src elisp :tangle gists/outline-minor-mode-eshell.el
|
||||
;; use C-c @ C-t to get a foldable shell history
|
||||
(use-package eshell
|
||||
:config
|
||||
(add-hook 'eshell-mode-hook
|
||||
(lambda () (setq-local outline-regexp eshell-prompt-regexp)))
|
||||
:hook
|
||||
(eshell-mode . outline-minor-mode))
|
||||
#+end_src
|
||||
|
||||
* Paredit inside minibuffer commands
|
||||
|
||||
Used [[https://github.com/purcell/emacs.d/blob/master/lisp/init-paredit.el][Purcell's configation]] as a starting point.
|
||||
|
||||
#+name: minibuffer-paredit
|
||||
#+begin_src elisp :tangle gists/minibuffer-paredit.el
|
||||
(use-package paredit
|
||||
:hook
|
||||
(minibuffer-setup . my/conditionally-enable-paredit-mode)
|
||||
(minibuffer-exit . my/restore-paredit-key)
|
||||
:config
|
||||
(defvar my/paredit-minibuffer-commands '(eval-expression
|
||||
pp-eval-expression
|
||||
eval-expression-with-eldoc
|
||||
ibuffer-do-eval
|
||||
ibuffer-do-view-and-eval
|
||||
org-ql-sparse-tree
|
||||
org-ql-search)
|
||||
"Interactive commands for which paredit should be enabled in the minibuffer.")
|
||||
|
||||
(defun my/conditionally-enable-paredit-mode ()
|
||||
"Enable paredit during lisp-related minibuffer commands."
|
||||
(when (memq this-command my/paredit-minibuffer-commands)
|
||||
(enable-paredit-mode)
|
||||
(unbind-key (kbd "RET") paredit-mode-map)))
|
||||
|
||||
(defun my/restore-paredit-key ()
|
||||
"Restore the RET binding that was disabled by
|
||||
my/conditionally-enable-paredit-mode."
|
||||
(bind-key (kbd "RET") #'paredit-newline paredit-mode-map)))
|
||||
#+end_src
|
||||
|
||||
* Store revision of Emacs configuration in a constant
|
||||
|
||||
#+begin_src elisp :tangle gists/store-configuration-revision-in-constant.el
|
||||
;; Store the Git revision of your Emacs configuration at the moment
|
||||
;; Emacs started.
|
||||
|
||||
(defconst my/has-git-p (if (executable-find "git") t nil)
|
||||
"Indicates if git is in your PATH.")
|
||||
|
||||
(defun my/configuration-revision ()
|
||||
"Retrieve the current Git revision of the Emacs configuration."
|
||||
(when my/has-git-p
|
||||
(with-temp-buffer
|
||||
(cd user-emacs-directory)
|
||||
(when (eql 0 (call-process "git" nil (current-buffer) nil
|
||||
"describe" "--all" "--long" "--dirty"))
|
||||
(string-trim (buffer-string))))))
|
||||
|
||||
(defconst my/configuration-revision
|
||||
(my/configuration-revision)
|
||||
"Contains the Git revision of the configuration at the moment Emacs started.")
|
||||
#+end_src
|
||||
|
||||
|
||||
* Meta
|
||||
** License
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
;; https://stackoverflow.com/questions/36039840/elisp-bind-a-lambda-in-a-let-and-execute-it
|
||||
|
||||
(let ((f (lambda (s) (message s))))
|
||||
;; f is a variable so should be treated as such.
|
||||
(funcall f "This works.")
|
||||
|
|
24
gists/minibuffer-paredit.el
Normal file
24
gists/minibuffer-paredit.el
Normal file
|
@ -0,0 +1,24 @@
|
|||
(use-package paredit
|
||||
:hook
|
||||
(minibuffer-setup . my/conditionally-enable-paredit-mode)
|
||||
(minibuffer-exit . my/restore-paredit-key)
|
||||
:config
|
||||
(defvar my/paredit-minibuffer-commands '(eval-expression
|
||||
pp-eval-expression
|
||||
eval-expression-with-eldoc
|
||||
ibuffer-do-eval
|
||||
ibuffer-do-view-and-eval
|
||||
org-ql-sparse-tree
|
||||
org-ql-search)
|
||||
"Interactive commands for which paredit should be enabled in the minibuffer.")
|
||||
|
||||
(defun my/conditionally-enable-paredit-mode ()
|
||||
"Enable paredit during lisp-related minibuffer commands."
|
||||
(when (memq this-command my/paredit-minibuffer-commands)
|
||||
(enable-paredit-mode)
|
||||
(unbind-key (kbd "RET") paredit-mode-map)))
|
||||
|
||||
(defun my/restore-paredit-key ()
|
||||
"Restore the RET binding that was disabled by
|
||||
my/conditionally-enable-paredit-mode."
|
||||
(bind-key (kbd "RET") #'paredit-newline paredit-mode-map)))
|
7
gists/outline-minor-mode-eshell.el
Normal file
7
gists/outline-minor-mode-eshell.el
Normal file
|
@ -0,0 +1,7 @@
|
|||
;; use C-c @ C-t to get a foldable shell history
|
||||
(use-package eshell
|
||||
:config
|
||||
(add-hook 'eshell-mode-hook
|
||||
(lambda () (setq-local outline-regexp eshell-prompt-regexp)))
|
||||
:hook
|
||||
(eshell-mode . outline-minor-mode))
|
18
gists/store-configuration-revision-in-constant.el
Normal file
18
gists/store-configuration-revision-in-constant.el
Normal file
|
@ -0,0 +1,18 @@
|
|||
;; Store the Git revision of your Emacs configuration at the moment
|
||||
;; Emacs started.
|
||||
|
||||
(defconst my/has-git-p (if (executable-find "git") t nil)
|
||||
"Indicates if git is in your PATH.")
|
||||
|
||||
(defun my/configuration-revision ()
|
||||
"Retrieve the current Git revision of the Emacs configuration."
|
||||
(when my/has-git-p
|
||||
(with-temp-buffer
|
||||
(cd user-emacs-directory)
|
||||
(when (eql 0 (call-process "git" nil (current-buffer) nil
|
||||
"describe" "--all" "--long" "--dirty"))
|
||||
(string-trim (buffer-string))))))
|
||||
|
||||
(defconst my/configuration-revision
|
||||
(my/configuration-revision)
|
||||
"Contains the Git revision of the configuration at the moment Emacs started.")
|
Loading…
Reference in a new issue