From 6852a7307a6f3a70d32b44d4971f98a343a64c59 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 18 Jan 2022 18:16:01 -0600 Subject: Ahh --- lisp/+org.el | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'lisp/+org.el') 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 -- cgit 1.4.1-21-gabe81