From dbb6181a5d8b5aa14a46bb207ebaf6c7911c8ced Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 15 Jun 2022 10:26:10 -0500 Subject: aodifu --- lisp/+emacs.el | 13 +++++++++++-- lisp/+org.el | 37 +++++++++++++++++++++++++++++++++++++ lisp/+titlecase.el | 12 ++++++++---- 3 files changed, 56 insertions(+), 6 deletions(-) (limited to 'lisp') diff --git a/lisp/+emacs.el b/lisp/+emacs.el index 533d438..b4742da 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el @@ -206,8 +206,17 @@ Do this only if the buffer is not visiting a file." ;;; Hooks -(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) -(add-hook 'minibuffer-setup-hook 'cursor-intangible-mode) +(add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p) +(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) + +(defun +auto-create-missing-dirs () + "Automatically create missing directories when finding a file." + ;; https://emacsredux.com/blog/2022/06/12/auto-create-missing-directories/ + (let ((target-dir (file-name-directory buffer-file-name))) + (unless (file-exists-p target-dir) + (make-directory target-dir t)))) + +(add-hook 'find-file-not-found-functions #'+auto-create-missing-dirs) ;;; Better-default functions ... diff --git a/lisp/+org.el b/lisp/+org.el index 0d6e300..6b956ae 100644 --- a/lisp/+org.el +++ b/lisp/+org.el @@ -729,5 +729,42 @@ When called with a prefix ARG, will still unconditionally call ((org-at-table-p) #'org-table-wrap-region) (t #'org-return))))) + +;;; el-patch + +(el-patch-defun org-format-outline-path (path &optional width prefix separator) + "Format the outline path PATH for display. +WIDTH is the maximum number of characters that is available. +PREFIX is a prefix to be included in the returned string, +such as the file name. +SEPARATOR is inserted between the different parts of the path, +the default is \"/\"." + (setq width (or width 79)) + (setq path (delq nil path)) + (unless (> width 0) + (user-error "Argument `width' must be positive")) + (setq separator (or separator "/")) + (let* ((org-odd-levels-only nil) + (fpath (concat + prefix (and prefix path separator) + (mapconcat + (lambda (s) (replace-regexp-in-string "[ \t]+\\'" "" s)) + (cl-loop for head in path + for n from 0 + collect (el-patch-swap + (org-add-props + head nil 'face + (nth (% n org-n-level-faces) org-level-faces)) + head)) + separator)))) + (when (> (length fpath) width) + (if (< width 7) + ;; It's unlikely that `width' will be this small, but don't + ;; waste characters by adding ".." if it is. + (setq fpath (substring fpath 0 width)) + (setf (substring fpath (- width 2)) ".."))) + fpath)) + + (provide '+org) ;;; +org.el ends here diff --git a/lisp/+titlecase.el b/lisp/+titlecase.el index 1366a46..655ebe1 100644 --- a/lisp/+titlecase.el +++ b/lisp/+titlecase.el @@ -4,10 +4,14 @@ ;;; Code: -(defun +titlecase-sentence-style-dwim () - "Titlecase a sentence." - (interactive) - (titlecase-dwim 'sentence)) +(defun +titlecase-sentence-style-dwim (&optional arg) + "Titlecase a sentence. +With prefix ARG, toggle the value of +`titlecase-downcase-sentences' before sentence-casing." + (interactive "P") + (let ((titlecase-downcase-sentences (if arg (not titlecase-downcase-sentences) + titlecase-downcase-sentences))) + (titlecase-dwim 'sentence))) (defun +titlecase-org-headings () (interactive) -- cgit 1.4.1-21-gabe81