about summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+emacs.el13
-rw-r--r--lisp/+org.el37
-rw-r--r--lisp/+titlecase.el12
3 files changed, 56 insertions, 6 deletions
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."
206 206
207;;; Hooks 207;;; Hooks
208 208
209(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) 209(add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
210(add-hook 'minibuffer-setup-hook 'cursor-intangible-mode) 210(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
211
212(defun +auto-create-missing-dirs ()
213 "Automatically create missing directories when finding a file."
214 ;; https://emacsredux.com/blog/2022/06/12/auto-create-missing-directories/
215 (let ((target-dir (file-name-directory buffer-file-name)))
216 (unless (file-exists-p target-dir)
217 (make-directory target-dir t))))
218
219(add-hook 'find-file-not-found-functions #'+auto-create-missing-dirs)
211 220
212 221
213;;; Better-default functions ... 222;;; 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
729 ((org-at-table-p) #'org-table-wrap-region) 729 ((org-at-table-p) #'org-table-wrap-region)
730 (t #'org-return))))) 730 (t #'org-return)))))
731 731
732
733;;; el-patch
734
735(el-patch-defun org-format-outline-path (path &optional width prefix separator)
736 "Format the outline path PATH for display.
737WIDTH is the maximum number of characters that is available.
738PREFIX is a prefix to be included in the returned string,
739such as the file name.
740SEPARATOR is inserted between the different parts of the path,
741the default is \"/\"."
742 (setq width (or width 79))
743 (setq path (delq nil path))
744 (unless (> width 0)
745 (user-error "Argument `width' must be positive"))
746 (setq separator (or separator "/"))
747 (let* ((org-odd-levels-only nil)
748 (fpath (concat
749 prefix (and prefix path separator)
750 (mapconcat
751 (lambda (s) (replace-regexp-in-string "[ \t]+\\'" "" s))
752 (cl-loop for head in path
753 for n from 0
754 collect (el-patch-swap
755 (org-add-props
756 head nil 'face
757 (nth (% n org-n-level-faces) org-level-faces))
758 head))
759 separator))))
760 (when (> (length fpath) width)
761 (if (< width 7)
762 ;; It's unlikely that `width' will be this small, but don't
763 ;; waste characters by adding ".." if it is.
764 (setq fpath (substring fpath 0 width))
765 (setf (substring fpath (- width 2)) "..")))
766 fpath))
767
768
732(provide '+org) 769(provide '+org)
733;;; +org.el ends here 770;;; +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 @@
4 4
5;;; Code: 5;;; Code:
6 6
7(defun +titlecase-sentence-style-dwim () 7(defun +titlecase-sentence-style-dwim (&optional arg)
8 "Titlecase a sentence." 8 "Titlecase a sentence.
9 (interactive) 9With prefix ARG, toggle the value of
10 (titlecase-dwim 'sentence)) 10`titlecase-downcase-sentences' before sentence-casing."
11 (interactive "P")
12 (let ((titlecase-downcase-sentences (if arg (not titlecase-downcase-sentences)
13 titlecase-downcase-sentences)))
14 (titlecase-dwim 'sentence)))
11 15
12(defun +titlecase-org-headings () 16(defun +titlecase-org-headings ()
13 (interactive) 17 (interactive)