Remove the facility to tangle into user-emacs-directory/site-lisp

This commit is contained in:
Gerard Vermeulen 2024-02-14 09:28:39 +01:00
parent 7b6177ccf8
commit f067cda41e
1 changed files with 11 additions and 85 deletions

View File

@ -352,33 +352,9 @@ recommendation of [[info:emacs#Saving Customizations][saving customizations (inf
(when (eq window-system 'ns)
(add-to-list 'initial-frame-alist '(height . 51))
(add-to-list 'initial-frame-alist '(width . 180)))
#+end_src
#+caption[Handle ~user-emacs-directory~ site-lisp directories as packages]:
#+caption: Handle ~user-emacs-directory~ site-lisp directories as packages.
#+name: lst:site-lisp-packages
#+begin_src emacs-lisp -n :results silent
(with-eval-after-load 'emacs
;; https://www.emacswiki.org/emacs/LoadPath
;; Make user-emacs-directory site-lisp directories look like packages.
(mapc (apply-partially 'add-to-list 'load-path)
(cl-remove-duplicates
(mapcar (lambda (file)
(directory-file-name (file-name-directory file)))
(directory-files-recursively
(expand-file-name "site-lisp" user-emacs-directory) "\\.el$"))
:test #'string=))
;; See package.el for how to use `loaddefs-generate-dir'.
(defun make-loaddefs-in-buffer-directory ()
"Make or update the autoloads in the directory of the visited file."
(interactive)
(let ((dir (directory-file-name (file-name-directory (buffer-file-name))))
(name (file-name-base (directory-file-name
(file-name-directory (buffer-file-name))))))
(loaddefs-generate dir
(expand-file-name (format "%s-autoloads.el" name) dir)
nil nil nil 'generate-full))))
(when (file-exists-p custom-file)
(load custom-file))
#+end_src
* [[info:emacs#Package Installation][Install the selected packages (info)]]
@ -2335,7 +2311,7 @@ of the [[info:org#Top][Org (info)]] manual.
:CUSTOM_ID: sec:setup-org
:END:
I have split the initial [[https://orgmode.org/][Org-mode]] setup over fourteen listings. Here, follows a
I have split the initial [[https://orgmode.org/][Org-mode]] setup over thirteen listings. Here, follows a
list detailing and motivating each listing:
1. Listing [[lst:set-org-options]] handles basic [[https://orgmode.org/][Org-mode]] options.
2. Listing [[lst:undo-org-ctags]] undoes ~org-ctags~. See [[https://list.orgmode.org/87mt43agk6.fsf@localhost/][org-ctags land grab]] for
@ -2345,26 +2321,22 @@ list detailing and motivating each listing:
4. Listing [[lst:fake-org-babel-functions]] adds =org-babel-execute:<LANGUAGE>=
functions to silence src_emacs-lisp[:results silent]{(find-library
"org-lint")}.
5. Listing [[lst:ob-tangle-plus]] extends [[info:org#Noweb Reference Syntax][source code export (info)]] with the
possibility to tangle of for instance Emacs Lisp files (or other programming
mode files) into a directory specified by ~org-babel-post-tangle-dir~ which
~toggle-post-tangle-hook-dir-usage~ may change.
6. Listing [[lst:set-org-link-options]] handles [[https://orgmode.org/][Org-mode]] options specific to
5. Listing [[lst:set-org-link-options]] handles [[https://orgmode.org/][Org-mode]] options specific to
[[info:org#Hyperlinks][hyperlinks (info)]].
7. Listing [[lst:setup-org-mode-map-1]] and [[lst:setup-org-mode-map-2]] extend the
6. Listing [[lst:setup-org-mode-map-1]] and [[lst:setup-org-mode-map-2]] extend the
=org-mode-map= with useful key-bindings.
8. Listing [[lst:setup-org-src]] facilitates [[info:org#Editing Source Code][editing source code blocks]], and it
7. Listing [[lst:setup-org-src]] facilitates [[info:org#Editing Source Code][editing source code blocks]], and it
provides functions to change the indentation of all =org-src-mode= blocks.
9. Listing [[lst:setup-ob-python]] allows to pretty-print Python session source
8. Listing [[lst:setup-ob-python]] allows to pretty-print Python session source
block values with [[https://github.com/psf/black#readme][black]] instead of [[https://docs.python.org/3/library/pprint.html][pprint]]. This snippet may break in the
future, because it sets =org-babel-python--def-format-value= which is a
constant declared "private" by two dashes in its name!
10. Listing [[lst:set-org-export-options]] selects the =non-intrusive= expert user
interface for export dispatching.
11. Listing [[lst:setup-org-for-lualatex-export]] and
9. Listing [[lst:set-org-export-options]] selects the =non-intrusive= expert user
interface for export dispatching.
10. Listing [[lst:setup-org-for-lualatex-export]] and
[[lst:set-ox-latex-options-for-lualatex-export]] configure [[https://orgmode.org/][Org-mode]] to generate
output for the LuaLaTeX compiler.
12. Listing [[lst:setup-org-latex-classes]] defines [[info:org#LaTeXspecificexportsettings][org-latex-classes (info)]] for
11. Listing [[lst:setup-org-latex-classes]] defines [[info:org#LaTeXspecificexportsettings][org-latex-classes (info)]] for
backward compatibility. Type {{{kbd(C-h v org-latex-classes)}}} for an
explanation of the code in listing [[lst:setup-org-latex-classes]].
@ -2473,52 +2445,6 @@ list detailing and motivating each listing:
"NO-OP to silence warnings." nil)
#+end_src
#+caption[Change the =org-babel-tangle= destination to a specific directory]:
#+caption: Change the =org-babel-tangle= destination to a specific directory.
#+name: lst:ob-tangle-plus
#+begin_src emacs-lisp -n :results silent
(with-eval-after-load 'emacs
;; Modified from https://emacs.stackexchange.com/a/61364 which replies to
;; https://emacs.stackexchange.com/questions/61359/
;; "How to specify a directory to tangle all code blocks into".
;; Org usage example, add a line: #+property: tangle-dir ./site-lisp/
(defcustom org-babel-post-tangle-dir nil
"Destination directory used by `dir+org-babel-post-tangle'.
Is subject to change by `toggle-post-tangle-hook-dir-usage'."
:group 'org-babel)
(defcustom org-babel-post-tangle-dir-modes '(emacs-lisp-mode)
"Modes for which `dir+org-babel-post-tangle' does what it has to do."
:group 'org-babel)
(defun org-babel-post-tangle-into ()
"Function to hook on `org-babel-post-tangle-hook'."
(when (and org-babel-post-tangle-dir
(derived-mode-p org-babel-post-tangle-dir-modes))
(let ((bfn (buffer-file-name)))
(unless (or (string-suffix-p "init.el" bfn)
(string-suffix-p "dir-locals.el" bfn))
(message "Tangle file `%S' into `%S'"
bfn org-babel-post-tangle-dir)
(rename-file bfn org-babel-post-tangle-dir t)))))
(defun org-babel-toggle-post-tangle-into ()
"Toggle tangling to `org-babel-post-tangle-dir'."
(interactive)
(if (member 'org-babel-post-tangle-into org-babel-post-tangle-hook)
(progn
(setq org-babel-post-tangle-dir nil)
(message "Disable tangling (into `%S')" org-babel-post-tangle-dir)
(remove-hook 'org-babel-post-tangle-hook #'org-babel-post-tangle-into))
(setq org-babel-post-tangle-dir
(expand-file-name (org-entry-get nil "tangle-dir" t)
user-emacs-directory))
(message "Enable tangling (into `%S')" org-babel-post-tangle-dir)
(add-hook 'org-babel-post-tangle-hook
#'org-babel-post-tangle-into))))
#+end_src
#+caption[Set =org-link= options]:
#+caption: Set =org-link= options.
#+name: lst:set-org-link-options