From 6852a7307a6f3a70d32b44d4971f98a343a64c59 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 18 Jan 2022 18:16:01 -0600 Subject: Ahh --- init.el | 22 ++++++++++++---------- lisp/+org.el | 47 +++++++++++++++++++++++++++++++++++++++++++++-- lisp/acdw.el | 2 +- 3 files changed, 58 insertions(+), 13 deletions(-) diff --git a/init.el b/init.el index e03e28f..0011380 100644 --- a/init.el +++ b/init.el @@ -490,14 +490,14 @@ "|" "DONE(d!)") (sequence "|" "CANCELED(k!)") (sequence "MEETING(m)"))) - (setf (alist-get "\\.x?html?\\'" org-file-apps nil nil #'equal) - #'+org-open-html) (:bind "RET" #'+org-return-dwim "" #'+org-table-copy-down "C-c C-l" #'+org-insert-link-dwim "C-c C-n" #'+org-next-heading-widen "C-c C-p" #'+org-previous-heading-widen - "C-c C-o" #'+org-open-at-point-dwim) + "C-c C-o" #'+org-open-at-point-dwim + "`" #'+org-insert-tilde + "~" #'+org-insert-backtick) (:local-hook user-save-hook #'+org-before-save@prettify-buffer) (advice-add #'org-delete-backward-char :override #'+org-delete-backward-char) ;; (define-advice org-open-at-point (:around (fn &rest r) open-external) @@ -506,7 +506,9 @@ ;; (apply fn r))) (with-eval-after-load 'org (org-clock-persistence-insinuate) - (org-link-set-parameters "tel" :follow #'+org-tel-open)) + (org-link-set-parameters "tel" :follow #'+org-tel-open) + (setf (alist-get "\\.x?html?\\'" org-file-apps nil nil #'equal) + #'+org-open-html)) ;; Extra keywords (font-lock-add-keywords 'org-mode @@ -514,12 +516,12 @@ ("^ *\\([-]\\) " (0 (compose-region (match-beginning 1) (match-end 1) "•"))) ("^ *\\([+]\\) " - (0 (compose-region (match-beginning 1) (match-end 1) "◦")))) - (with-eval-after-load 'form-feed - ;; Horizontal lines - (font-lock-add-keywords - 'org-mode - '(("^-----+" 0 'form-feed--font-lock-face t)))))) + (0 (compose-region (match-beginning 1) (match-end 1) "◦"))))) + (with-eval-after-load 'form-feed + ;; Horizontal lines + (font-lock-add-keywords + 'org-mode + '(("^-----+" . form-feed--font-lock-face))))) (setup org-agenda (:option org-agenda-skip-deadline-if-done t diff --git a/lisp/+org.el b/lisp/+org.el index 5869622..0f2c625 100644 --- a/lisp/+org.el +++ b/lisp/+org.el @@ -447,10 +447,53 @@ the deletion might narrow the column." (defun +org-open-html (file-path link-string) "Open FILE-PATH with `browse-url'. This function is intended to use with `org-file-apps'. See the -documentation of that function for a description of the two -arguments here, FILE-PATH and LINK-STRING." + documentation of that function for a description of the two + arguments here, FILE-PATH and LINK-STRING." (message "Opening %s (%s)..." file-path link-string) (browse-url file-path)) +(defun +org-insert-horizontal-rule (prefix) + "Insert a horizontal rule (-----) after the current line. +With PREFIX, insert before the current line." + (interactive "P") + (if prefix + (move-beginning-of-line nil) + (move-end-of-line nil) + (forward-line 1)) + (insert "-----\n")) + +;;; Make code snippets in org-mode easier to type +;; http://mbork.pl/2022-01-17_Making_code_snippets_in_Org-mode_easier_to_type + +(defun +org-insert-backtick () + "Insert a backtick using `org-self-insert-command'." + (interactive) + (setq last-command-event ?`) + (call-interactively #'org-self-insert-command)) + +(defvar-local +org-insert-tilde-language nil + "Default language name in the current Org file. +If nil, `org-insert-tilde' after 2 tildes inserts an \"example\" +block. If a string, it inserts a \"src\" block with the given +language name.") + +(defun +org-insert-tilde () + "Insert a tilde using `org-self-insert-command'." + (interactive) + (if (string= (buffer-substring-no-properties (- (point) 3) (point)) + "\n~~") + (progn (delete-char -2) + (if +org-insert-tilde-language + (insert (format "#+begin_src %s\n#+end_src" + +org-insert-tilde-language)) + (insert "#+begin_example\n#+end_example")) + (forward-line -1) + (if (string= +org-insert-tilde-language "") + (move-end-of-line nil) + ;;(org-edit-special) ; Useful really only with splits. + )) + (setq last-command-event ?~) + (call-interactively #'org-self-insert-command))) + (provide '+org) ;;; +org.el ends here diff --git a/lisp/acdw.el b/lisp/acdw.el index 17741ab..28ea108 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -128,7 +128,7 @@ I keep forgetting how they differ." (defmacro +defvar (var value &rest _) "Quick way to `setq' a variable from a `defvar' form." - (declare (doc-string 3)) + (declare (doc-string 3) (indent 2)) `(setq ,var ,value)) (defmacro +with-message (message &rest body) -- cgit 1.4.1-21-gabe81