diff --git a/init.org b/init.org index 77a1432..9011559 100644 --- a/init.org +++ b/init.org @@ -783,7 +783,7 @@ _u_: next word ^_l_: edit lines^ _s_: next whole symbol ("L" my-literate-elisp-hydra/body "literate-elisp") ("p" org-set-property "property") ("l" my-org-hydra-block/body "source block") - ("t" my-org-hydra-set-tags "tags") + ("t" my-org-set-tags "tags") ("C-t" org-todo "todo" :color red) ("v" my-org-hydra-nav/body "navigation") ("b" (my-compile-org-lp) "compile") @@ -3822,7 +3822,6 @@ SLIME opens CLHS links in Firefox, but I'd rather open them in Tor Browser; Tor ;; "C-m" 'org-return-indent "C-c C-9" 'org-mark-ring-goto "C-c C-/" 'org-sparse-tree - "M-w" 'cp-copy-line-or-link "C-M-x" 'cp/eval-sexp "C-c C-o" 'my-org-open ;; boon @@ -3865,30 +3864,40 @@ SLIME opens CLHS links in Firefox, but I'd rather open them in Tor Browser; Tor (org-link-set-parameters "gemini" :export #'my-export-gemini-link) (org-link-set-parameters "xmpp" :export #'my-export-xmpp-link)) - ;; https://lists.gnu.org/archive/html/emacs-orgmode/2018-02/msg00082.html - (defun my-export-link-helper (link desc format) - (cond - ((eq format 'html) - (format "%s" link desc)) - ((eq format 'latex) - ;; (format "\\href{%s}{%s}" link desc) - (format "\\url{%s}" link)) - (t ;; `ascii', `md', `hugo', etc. - (format "[%s](%s)" desc link)))) +(defun contrapunctus-disable-nameless-key () + (define-key nameless-mode-map (kbd "C-c C--") nil)) +#+END_SRC +*** gemini: and xmpp: links +https://lists.gnu.org/archive/html/emacs-orgmode/2018-02/msg00082.html +#+BEGIN_SRC emacs-lisp +(defun my-export-link-helper (link desc format) + (cond + ((eq format 'html) + (format "%s" link desc)) + ((eq format 'latex) + ;; (format "\\href{%s}{%s}" link desc) + (format "\\url{%s}" link)) + (t ;; `ascii', `md', `hugo', etc. + (format "[%s](%s)" desc link)))) +#+END_SRC + +#+BEGIN_SRC emacs-lisp (defun my-export-gemini-link (link desc format) "Create export version of LINK and DESC to FORMAT." (let ((link (concat "gemini:" link))) (my-export-link-helper link desc format))) +#+END_SRC +#+BEGIN_SRC emacs-lisp (defun my-export-xmpp-link (link desc format) "Create export version of LINK and DESC to FORMAT." (let ((link (concat "xmpp:" link))) (my-export-link-helper link desc format))) +#+END_SRC - (defun contrapunctus-disable-nameless-key () - (define-key nameless-mode-map (kbd "C-c C--") nil)) - +*** my-org-insert-block +#+BEGIN_SRC emacs-lisp (defun my-org-insert-block (type &optional lang header-args ask) "Insert block of TYPE at point, or at beginning and end of region. TYPE should be an Org block type, e.g. SRC, QUOTE, etc. @@ -3934,7 +3943,9 @@ or with ASK, prompt the user for a language." (insert "\n" end-string) (goto-char point-inside-block) (insert indent)))))) +#+END_SRC +#+BEGIN_SRC emacs-lisp ;; (use-package org-src-mode ;; :hook (org-src-mode . (lambda () (when (derived-mode-p 'emacs-lisp-mode))))) @@ -3945,7 +3956,10 @@ or with ASK, prompt the user for a language." ;; ;; todo - check if we are on a heading ;; (org-forward-heading-same-level) ;; ()) +#+END_SRC +*** my-org-open +#+BEGIN_SRC emacs-lisp ;; I dislike having to navigate within a line to reach a link - with ;; this command I just need to be on the same line as the link. (defun my-org-open (&optional arg reference-buffer) @@ -3954,57 +3968,10 @@ or with ASK, prompt the user for a language." (unless (looking-at-p (rx-to-string '(or "http" "["))) (org-next-link)) (org-open-at-point)) +#+END_SRC -(defun cp-copy-line-or-link (prefix-arg) - "Copy address of org-mode link after point, ignoring whitespace, -link description (if any) and org-mode header and list syntax. If -not before a link, or with a prefix arg, call -`whole-line-or-region-kill-ring-save' instead. - -BUG - improper behaviour with checkboxes. -2018-03-17T21:15:17+0530 - hopefully fixed now." - (interactive "P") - (let ((point-a (point))) - (cl-flet ((copy-to-closing-bracket - () - (let ((point-b (point))) - (re-search-forward "\\]") - (copy-region-as-kill point-b - (- (point) 1))))) - - (if (save-excursion - (or (use-region-p) - prefix-arg - (cp/re-search-line "\\[[-X ]\\]"))) - (whole-line-or-region-kill-ring-save prefix-arg) - - (cond ( ;; (cp/org-link-ahead-p) - (cp/re-search-line "\\[") - ;; (if (looking-at "\\[") - ;; (forward-char)) - (forward-char) - (copy-to-closing-bracket) - (goto-char point-a)) - - ( ;; (cp/org-link-ahead-p 'implicit) - (cp/re-search-line "http") - (backward-word) - (let ((point-b (point))) - (re-search-forward (rx (or eol (and printing " ")))) - (copy-region-as-kill point-b - (point))) - (goto-char point-a)) - - ;; TODO - org-previous-link will land you at the start - ;; of the DESCRIPTION of the previous link, if it has - ;; one, but to the user it will look like they are at - ;; the start of the link. Add a case to handle this. - - ;; Does not work if there is an org TODO marker in a - ;; header. - - (t (whole-line-or-region-kill-ring-save prefix-arg))))))) - +*** org-table-convert-tsv +#+BEGIN_SRC emacs-lisp (defun cp/org-table-convert-tsv () (interactive) (with-output-to-temp-buffer "cp/org-table-convert-tsv" @@ -4015,8 +3982,11 @@ BUG - improper behaviour with checkboxes. (with-current-buffer "cp/org-table-convert-tsv" (remove-hook 'before-save-hook 'delete-trailing-whitespace) (write-file (read-from-minibuffer "Output filename: ")))) +#+END_SRC -(defun my-org-hydra-set-tags () +*** my-org-set-tags - using completing-read-multiple for setting tags +#+BEGIN_SRC emacs-lisp +(defun my-org-set-tags () (interactive) (let ((all-tags (org-get-buffer-tags)) (current-tags (org-get-tags))) @@ -4027,7 +3997,10 @@ BUG - improper behaviour with checkboxes. "Tag: " all-tags nil 'confirm (mapconcat #'identity current-tags ",") 'org-tags-history))))) +#+END_SRC +*** +#+BEGIN_SRC emacs-lisp (defun cp/marked-files->markup-links-org (filenames) (mapcar (lambda (filename) (let ((link-pre "[[file:") @@ -4036,18 +4009,21 @@ BUG - improper behaviour with checkboxes. filenames)) #+END_SRC +*** my-org-insert-timestamp #+BEGIN_SRC emacs-lisp -(defun contrapunctus-org-insert-timestamp () +(defun my-org-insert-timestamp () (save-excursion (org-set-property "CREATED" (format-time-string "%FT%T%z")))) (use-package org-indent :hook (org-mode . org-indent-mode)) -(use-package ox-texinfo - :hook (org-mode . (require 'ox-texinfo))) ;; ideally, I'd run this in :before advice for org-export... +(with-eval-after-load 'ox + (require 'ox-texinfo)) ;; ideally, I'd load this in :before advice for org-export... #+END_SRC +*** load org-babel languages on demand From https://emacs.stackexchange.com/questions/20577/org-babel-load-all-languages-on-demand + #+BEGIN_SRC emacs-lisp (defadvice org-babel-execute-src-block (around load-language nil activate) "Load language if needed"