about summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+org.el47
-rw-r--r--lisp/acdw.el2
2 files changed, 46 insertions, 3 deletions
diff --git a/lisp/+org.el b/lisp/+org.el index 11a816f..57a4a16 100644 --- a/lisp/+org.el +++ b/lisp/+org.el
@@ -451,10 +451,53 @@ the deletion might narrow the column."
451(defun +org-open-html (file-path link-string) 451(defun +org-open-html (file-path link-string)
452 "Open FILE-PATH with `browse-url'. 452 "Open FILE-PATH with `browse-url'.
453This function is intended to use with `org-file-apps'. See the 453This function is intended to use with `org-file-apps'. See the
454documentation of that function for a description of the two 454 documentation of that function for a description of the two
455arguments here, FILE-PATH and LINK-STRING." 455 arguments here, FILE-PATH and LINK-STRING."
456 (message "Opening %s (%s)..." file-path link-string) 456 (message "Opening %s (%s)..." file-path link-string)
457 (browse-url file-path)) 457 (browse-url file-path))
458 458
459(defun +org-insert-horizontal-rule (prefix)
460 "Insert a horizontal rule (-----) after the current line.
461With PREFIX, insert before the current line."
462 (interactive "P")
463 (if prefix
464 (move-beginning-of-line nil)
465 (move-end-of-line nil)
466 (forward-line 1))
467 (insert "-----\n"))
468
469;;; Make code snippets in org-mode easier to type
470;; http://mbork.pl/2022-01-17_Making_code_snippets_in_Org-mode_easier_to_type
471
472(defun +org-insert-backtick ()
473 "Insert a backtick using `org-self-insert-command'."
474 (interactive)
475 (setq last-command-event ?`)
476 (call-interactively #'org-self-insert-command))
477
478(defvar-local +org-insert-tilde-language nil
479 "Default language name in the current Org file.
480If nil, `org-insert-tilde' after 2 tildes inserts an \"example\"
481block. If a string, it inserts a \"src\" block with the given
482language name.")
483
484(defun +org-insert-tilde ()
485 "Insert a tilde using `org-self-insert-command'."
486 (interactive)
487 (if (string= (buffer-substring-no-properties (- (point) 3) (point))
488 "\n~~")
489 (progn (delete-char -2)
490 (if +org-insert-tilde-language
491 (insert (format "#+begin_src %s\n#+end_src"
492 +org-insert-tilde-language))
493 (insert "#+begin_example\n#+end_example"))
494 (forward-line -1)
495 (if (string= +org-insert-tilde-language "")
496 (move-end-of-line nil)
497 ;;(org-edit-special) ; Useful really only with splits.
498 ))
499 (setq last-command-event ?~)
500 (call-interactively #'org-self-insert-command)))
501
459(provide '+org) 502(provide '+org)
460;;; +org.el ends here 503;;; +org.el ends here
diff --git a/lisp/acdw.el b/lisp/acdw.el index a96e6a7..34d1bc4 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -128,7 +128,7 @@ I keep forgetting how they differ."
128 128
129(defmacro +defvar (var value &rest _) 129(defmacro +defvar (var value &rest _)
130 "Quick way to `setq' a variable from a `defvar' form." 130 "Quick way to `setq' a variable from a `defvar' form."
131 (declare (doc-string 3)) 131 (declare (doc-string 3) (indent 2))
132 `(setq ,var ,value)) 132 `(setq ,var ,value))
133 133
134(defmacro +with-message (message &rest body) 134(defmacro +with-message (message &rest body)