[org] move configuration to init.org

This commit is contained in:
contrapunctus 2021-02-18 10:56:52 +05:30
parent dad20b4938
commit 1d37f1e853
2 changed files with 258 additions and 258 deletions

View File

@ -1,257 +0,0 @@
(use-package org
:commands (org-drag-line-backward org-drag-line-forward)
:config
(general-def "<f5> o" 'org-mode)
(general-def org-mode-map
"C-," 'nil
"M-n" 'org-metadown
"M-p" 'org-metaup
"C-c C--" 'org-ctrl-c-minus
"C-c C-," 'org-metaleft
"C-c C-." 'org-metaright
;; "C-j" 'org-return
;; "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-c C-]" 'cp-org-set-tags
"C-M-x" 'cp/eval-sexp
"C-c C-o" 'cp/org-open
;; boon
"C-c C--" 'org-ctrl-c-minus
"C-c ]" 'cp-org-set-tags
"C-c ," 'org-metaleft
"C-c ." 'org-metaright)
(mapc (lambda (pair)
(add-to-list 'org-file-apps pair))
'(("txt" . emacs)
("org" . emacs)
;; ("pdf" . zathura)
("\\(?:gif\\|jpe?g\\|png\\)" . "sxiv -f %s")
;; (t . "xdg-open %s")
("pdf" . system)
;; ("pdf" . "zathura %s")
;; (auto-mode . emacs)
;; (system . "xdg-open %s")
(system . "zathura %s")
;; (t . system)
))
(setq org-todo-keywords '((sequence "TODO" "RESEARCH" "STARTED" "DONE"))
org-image-actual-width 400
org-cycle-include-plain-lists 'integrate
org-link-search-must-match-exact-headline nil
org-html-head
;; made to resemble Firefox's reader mode, dark setting
"<style type=text/css>
body {
margin: 40px auto;
max-width: 650px;
line-height: 1.6;
font-size: 18px;
color: #eeeeee !important;
padding: 0 10px;
background-color: #333333;
font-family: sans-serif;
}
h1,h2,h3 {
line-height: 1.2;
}
a,a:visited {
color: #07a;
}
img {
max-width: 80%;
height: auto;
width: auto\9; /* ie8 */
}
</style>"
;; ;; mix of motherfuckingwebsite.com + bettermotherfuckingwebsite.com + thebestmotherfucking.website
;; "<style type=text/css>
;; body {
;; margin: 40px auto;
;; max-width: 650px;
;; line-height: 1.6;
;; font-size: 18px;
;; color: #444;
;; padding: 0 10px;
;; background-color: #eeeeee;
;; font-family: sans-serif;
;; }
;; h1,h2,h3 {
;; line-height: 1.2;
;; }
;; a,a:visited {
;; color: #07a;
;; }
;; img {
;; max-width: 80%;
;; height: auto;
;; width: auto\9; /* ie8 */
;; }
;; </style>"
org-export-default-inline-image-rule
`(("https" .
,(format "\\.%s\\'"
(regexp-opt
'("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm"
"xpm" "pbm" "pgm" "ppm" "webp") t)))
("file" .
,(format "\\.%s\\'"
(regexp-opt
'("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm"
"xpm" "pbm" "pgm" "ppm" "webp") t)))))
;; https://lists.gnu.org/archive/html/emacs-orgmode/2018-02/msg00082.html
(defun org-link-gemini-export-link (link desc format)
"Create export version of LINK and DESC to FORMAT."
(let ((link (concat "gemini:" link)))
(cond
((eq format 'html)
(format "<a href=\"" link desc))
((eq format 'latex)
(format "\\href{%s}{%s}" link desc))
(t ;`ascii', `md', `hugo', etc.
(format "[%s](%s)" desc link)))))
(org-link-set-parameters "gemini" :export #'org-link-gemini-export-link))
;; TODO - if `region-active-p', insert syntax at region boundaries
(defun cp-org-insert-src (&optional lang)
(let* ((col (- (point) (point-at-bol)))
(indent (make-string col ?\ )))
(insert (format "#+BEGIN_SRC %s\n"
(if (stringp lang) lang "")))
(let ((pos (point)))
(insert (format "\n%s#+END_SRC" indent))
(goto-char pos)
(insert indent))))
(defhydra cp-org-src (:color blue)
"Org source block"
("e" (cp-org-insert-src "emacs-lisp") "Emacs Lisp"))
(defhydra cp-org (:color red)
"Org"
("p" org-set-property "property" :color blue)
("b" cp-org-src/body "source block" :color blue)
("t" cp-org-set-tags "tags" :color blue)
("i" org-previous-visible-heading "previous heading")
("o" org-next-visible-heading "next heading")
("j" outline-up-heading "up heading")
(";" outline-down-heading "down heading")
("k" org-backward-heading-same-level "backward heading")
("l" org-forward-heading-same-level "forward heading")
("I" org-drag-element-backward "drag backward")
("O" org-drag-element-forward "drag forward")
("J" org-promote-subtree "promote")
(":" org-demote-subtree "demote")
("s" save-buffer "save" :color blue)
("m" magit-status "Magit" :color blue)
("u" contrapunctus-general-hydra/body "up" :color blue)
("G" elpher "Elpher" :color blue))
;; (use-package org-src-mode
;; :hook (org-src-mode . (lambda () (when (derived-mode-p 'emacs-lisp-mode)))))
;; (defun cp-org-expand-all ()
;; (interactive)
;; ;; todo - define inner recursive function
;; (beginning-of-buffer)
;; ;; todo - check if we are on a heading
;; (org-forward-heading-same-level)
;; ())
;; 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 cp/org-open (&optional arg reference-buffer)
(interactive "P")
(beginning-of-visual-line)
(unless (looking-at-p (rx-to-string '(or "http" "[")))
(org-next-link))
(org-open-at-point))
(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)))))))
(defun cp/org-table-convert-tsv ()
(interactive)
(with-output-to-temp-buffer "cp/org-table-convert-tsv"
(->> (buffer-substring-no-properties (region-beginning) (region-end))
(replace-regexp-in-string "^| *" "")
(replace-regexp-in-string " *| *" " ")
(replace-regexp-in-string "^-.*$" "")))
(with-current-buffer "cp/org-table-convert-tsv"
(remove-hook 'before-save-hook 'delete-trailing-whitespace)
(write-file (read-from-minibuffer "Output filename: "))))
(defun cp-org-set-tags ()
(interactive)
(let ((all-tags (org-get-buffer-tags))
(current-tags (org-get-tags)))
(save-excursion
(org-back-to-heading)
(org-set-tags
(completing-read-multiple
"Tag: " all-tags nil 'confirm
(mapconcat #'identity current-tags ",")
'org-tags-history)))))
(use-package org-indent
:hook (org-mode . org-indent-mode))
(use-package ox-texinfo)
(provide 'cp-org)

259
init.org
View File

@ -885,6 +885,264 @@ Ask for confirmation before saving cookies. I'd rather just disallow them all th
#+END_SRC
** Org
#+BEGIN_SRC emacs-lisp
(use-package org
:commands (org-drag-line-backward org-drag-line-forward)
:config
(general-def "<f5> o" 'org-mode)
(general-def org-mode-map
"C-," 'nil
"M-n" 'org-metadown
"M-p" 'org-metaup
"C-c C--" 'org-ctrl-c-minus
"C-c C-," 'org-metaleft
"C-c C-." 'org-metaright
;; "C-j" 'org-return
;; "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-c C-]" 'cp-org-set-tags
"C-M-x" 'cp/eval-sexp
"C-c C-o" 'cp/org-open
;; boon
"C-c C--" 'org-ctrl-c-minus
"C-c ]" 'cp-org-set-tags
"C-c ," 'org-metaleft
"C-c ." 'org-metaright)
(mapc (lambda (pair)
(add-to-list 'org-file-apps pair))
'(("txt" . emacs)
("org" . emacs)
;; ("pdf" . zathura)
("\\(?:gif\\|jpe?g\\|png\\)" . "sxiv -f %s")
;; (t . "xdg-open %s")
("pdf" . system)
;; ("pdf" . "zathura %s")
;; (auto-mode . emacs)
;; (system . "xdg-open %s")
(system . "zathura %s")
;; (t . system)
))
(setq org-todo-keywords '((sequence "TODO" "RESEARCH" "STARTED" "DONE"))
org-image-actual-width 400
org-cycle-include-plain-lists 'integrate
org-link-search-must-match-exact-headline nil
org-html-head
;; made to resemble Firefox's reader mode, dark setting
"<style type=text/css>
body {
margin: 40px auto;
max-width: 650px;
line-height: 1.6;
font-size: 18px;
color: #eeeeee !important;
padding: 0 10px;
background-color: #333333;
font-family: sans-serif;
}
h1,h2,h3 {
line-height: 1.2;
}
a,a:visited {
color: #07a;
}
img {
max-width: 80%;
height: auto;
width: auto\9; /* ie8 */
}
</style>"
;; ;; mix of motherfuckingwebsite.com + bettermotherfuckingwebsite.com + thebestmotherfucking.website
;; "<style type=text/css>
;; body {
;; margin: 40px auto;
;; max-width: 650px;
;; line-height: 1.6;
;; font-size: 18px;
;; color: #444;
;; padding: 0 10px;
;; background-color: #eeeeee;
;; font-family: sans-serif;
;; }
;; h1,h2,h3 {
;; line-height: 1.2;
;; }
;; a,a:visited {
;; color: #07a;
;; }
;; img {
;; max-width: 80%;
;; height: auto;
;; width: auto\9; /* ie8 */
;; }
;; </style>"
org-export-default-inline-image-rule
`(("https" .
,(format "\\.%s\\'"
(regexp-opt
'("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm"
"xpm" "pbm" "pgm" "ppm" "webp") t)))
("file" .
,(format "\\.%s\\'"
(regexp-opt
'("png" "jpeg" "jpg" "gif" "tiff" "tif" "xbm"
"xpm" "pbm" "pgm" "ppm" "webp") t)))))
;; https://lists.gnu.org/archive/html/emacs-orgmode/2018-02/msg00082.html
(defun org-link-gemini-export-link (link desc format)
"Create export version of LINK and DESC to FORMAT."
(let ((link (concat "gemini:" link)))
(cond
((eq format 'html)
(format "<a href=\"" link desc))
((eq format 'latex)
(format "\\href{%s}{%s}" link desc))
(t ;`ascii', `md', `hugo', etc.
(format "[%s](%s)" desc link)))))
(org-link-set-parameters "gemini" :export #'org-link-gemini-export-link))
;; TODO - if `region-active-p', insert syntax at region boundaries
(defun cp-org-insert-src (&optional lang)
(let* ((col (- (point) (point-at-bol)))
(indent (make-string col ?\ )))
(insert (format "#+BEGIN_SRC %s\n"
(if (stringp lang) lang "")))
(let ((pos (point)))
(insert (format "\n%s#+END_SRC" indent))
(goto-char pos)
(insert indent))))
(defhydra cp-org-src (:color blue)
"Org source block"
("e" (cp-org-insert-src "emacs-lisp") "Emacs Lisp"))
(defhydra cp-org (:color red)
"Org"
("p" org-set-property "property" :color blue)
("b" cp-org-src/body "source block" :color blue)
("t" cp-org-set-tags "tags" :color blue)
("i" org-previous-visible-heading "previous heading")
("o" org-next-visible-heading "next heading")
("j" outline-up-heading "up heading")
(";" outline-down-heading "down heading")
("k" org-backward-heading-same-level "backward heading")
("l" org-forward-heading-same-level "forward heading")
("I" org-drag-element-backward "drag backward")
("O" org-drag-element-forward "drag forward")
("J" org-promote-subtree "promote")
(":" org-demote-subtree "demote")
("s" save-buffer "save" :color blue)
("m" magit-status "Magit" :color blue)
("u" contrapunctus-general-hydra/body "up" :color blue)
("G" elpher "Elpher" :color blue))
;; (use-package org-src-mode
;; :hook (org-src-mode . (lambda () (when (derived-mode-p 'emacs-lisp-mode)))))
;; (defun cp-org-expand-all ()
;; (interactive)
;; ;; todo - define inner recursive function
;; (beginning-of-buffer)
;; ;; todo - check if we are on a heading
;; (org-forward-heading-same-level)
;; ())
;; 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 cp/org-open (&optional arg reference-buffer)
(interactive "P")
(beginning-of-visual-line)
(unless (looking-at-p (rx-to-string '(or "http" "[")))
(org-next-link))
(org-open-at-point))
(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)))))))
(defun cp/org-table-convert-tsv ()
(interactive)
(with-output-to-temp-buffer "cp/org-table-convert-tsv"
(->> (buffer-substring-no-properties (region-beginning) (region-end))
(replace-regexp-in-string "^| *" "")
(replace-regexp-in-string " *| *" " ")
(replace-regexp-in-string "^-.*$" "")))
(with-current-buffer "cp/org-table-convert-tsv"
(remove-hook 'before-save-hook 'delete-trailing-whitespace)
(write-file (read-from-minibuffer "Output filename: "))))
(defun cp-org-set-tags ()
(interactive)
(let ((all-tags (org-get-buffer-tags))
(current-tags (org-get-tags)))
(save-excursion
(org-back-to-heading)
(org-set-tags
(completing-read-multiple
"Tag: " all-tags nil 'confirm
(mapconcat #'identity current-tags ",")
'org-tags-history)))))
(use-package org-indent
:hook (org-mode . org-indent-mode))
(use-package ox-texinfo)
#+END_SRC
** markdown-mode :editing:
#+BEGIN_SRC emacs-lisp
(use-package markdown-mode
@ -1818,7 +2076,6 @@ Must put this after loading the custom file, or I get prompted about the theme e
**
#+BEGIN_SRC emacs-lisp
(require 'cp-org)
(require 'cp-desktop)
(require 'cp-mail)
#+END_SRC