;;; init-org.el --- Initialize Org mode -*- lexical-binding: t -*- ;;; Commentary: ;; https://orgmode.org/ ;; https://git.savannah.gnu.org/cgit/emacs/org-mode.git/ ;;; Code: (require 'org) (require 'org-agenda) (require 'ox) (require 'ox-html) (require 'ox-publish) (keymap-global-set "C-S-a" #'org-agenda-list) (keymap-set org-mode-map "C-c RET" #'org-meta-return) (keymap-set org-mode-map "C-v" #'org-yank) (keymap-set org-mode-map "C-y" #'undo-redo) (setq org-agenda-custom-commands '(("|" "Agenda without preset filters" agenda "" ((org-agenda-tag-filter-preset nil))))) (setq org-agenda-deadline-leaders '(nil "+%dd" "-%dd")) (setq org-agenda-files '("~/main/t/tasks")) (setq org-agenda-format-date "%a, %b %d") ; https://www.gnu.org/software/emacs/manual/html_node/elisp/Time-Parsing.html (setq org-agenda-overriding-header "") (setq org-agenda-prefix-format '((agenda . "%-5s %-5t [%c] "))) (setq org-agenda-scheduled-leaders '(nil "-%dd")) (setq org-agenda-span 13) ; 14+ causes the previous day to be displayed. (setq org-agenda-start-day nil) (setq org-agenda-tag-filter-preset '("-hide")) (setq org-agenda-time-grid '((daily today require-timed) () nil nil)) (setq org-agenda-time-leading-zero t) (setq org-agenda-todo-keyword-format "") (setq org-agenda-use-time-grid nil) (setq org-agenda-window-setup 'current-window) (setq org-blank-before-new-entry nil) (setq org-deadline-warning-days 9) ; More space is needed for earlier warnings. (setq org-entities-user '(("NoBreak" nil nil "⁠"))) (setq org-export-global-macros '(("date" . "(eval (format-time-string \"%Y-%m-%d\"))"))) (setq org-export-timestamp-file nil) ; Why does Flymake sometimes identify this as a free variable? (setq org-export-with-author nil) (setq org-export-with-broken-links t) (setq org-export-with-section-numbers nil) (setq org-export-with-smart-quotes nil) (setq org-export-with-sub-superscripts nil) (setq org-export-with-toc nil) (setq org-fontify-done-headline nil) (setq org-footnote-auto-adjust t) (setq org-footnote-section nil) (setq org-html--pre/postamble-class "") (setq org-html-content-class "") (setq org-html-doctype "html5") (setq org-html-head-include-default-style nil) (setq org-html-postamble nil) (setq org-html-preamble nil) (setq org-html-xml-declaration nil) (setq org-link-frame-setup '((file . find-file))) (setq org-log-repeat nil) (setq org-priority-default 2) (setq org-priority-highest 1) (setq org-priority-lowest 3) (setq org-publish-use-timestamps-flag nil) (setq org-startup-folded nil) (setq org-startup-indented t) (setq org-tags-column 0) ;; Remove problematic punctuation marks from emphasis prematch and postmatch. ;; For example, remove hyphens and quotation marks because of these problems: ;; https://example.com/-/thisSlugWasItalicized/ ;; https://example.com/?q="phrase"+"thisPhraseWasStruckthrough"+"phrase" (setq org-emphasis-regexp-components '("[:space:](" "[:space:].,:!?;)" "[:space:]" "." 1)) (setq org-html-head (concat "")) (setq org-link-abbrev-alist '(("aliexpress" . "https://www.aliexpress.us/wholesale?sortType=total_tranpro_desc&SearchText=") ("amazon" . "https://www.amazon.com/s?k=") ("amazonbestsellers" . "https://www.amazon.com/-/zgbs/-/") ("amazonbooks" . "https://www.amazon.com/s?i=stripbooks&k=") ("amazontechbooks" . "https://www.amazon.com/s?rh=n%3A5&k=") ("archforums" . "https://www.google.com/search?nfpr=1&num=100&q=site:bbs.archlinux.org+|+site:lists.archlinux.org+|+site:www.reddit.com/r/archlinux+") ("archpackages" . "https://archlinux.org/packages/?q=") ("alternativeto" . "https://www.google.com/search?nfpr=1&num=100&q=site:alternativeto.net+") ("benchmarks" . "https://www.google.com/search?nfpr=1&num=100&q=benchmark+|+benchmarks+|+benchmarking+") ("bestbuy" . "https://www.bestbuy.com/site/searchpage.jsp?st==") ("bestpractices" . "https://www.google.com/search?nfpr=1&num=100&q=\"best+practices\"+|+\"conventions\"+|+\"style\"+") ("bgg" . "https://boardgamegeek.com/search/boardgame?q=") ("boardgameforums" . "https://www.google.com/search?nfpr=1&num=100&q=site:boardgamegeek.com/thread+|+site:www.reddit.com/r/boardgames+") ("boardgameoracle" . "https://www.boardgameoracle.com/boardgame/search?q=") ("camelcamelcamel" . "http://camelcamelcamel.com/products?sq=") ("chewy" . "https://www.chewy.com/s?query=") ("chromewebstore" . "https://www.google.com/search?nfpr=1&num=100&q=site:chrome.google.com/webstore+") ("costco" . "https://www.costco.com/s?keyword=") ("coupons" . "https://www.google.com/search?nfpr=1&num=100&q=coupon+|+coupons+") ("crates" . "https://crates.io/search?sort=recent-downloads&q=") ("dbmigrations" . "https://www.google.com/search?nfpr=1&num=100&q=\"manage.py+migrate\"+|+\"rails+db:migrate\"+|+\"prisma+migrate\"+|+\"artisan+migrate\"+") ("debianforums" . "https://www.google.com/search?nfpr=1&num=100&q=site:lists.debian.org+|+site:forums.debian.net+|+site:reddit.com/r/debian+") ("debianman" . "https://dyn.manpages.debian.org/jump?suite=unstable&q=") ("debianpackages" . "https://packages.debian.org/search?keywords=") ("debianpackagesall" . "https://packages.debian.org/search?suite=sid&searchon=all&exact=1&keywords=") ("debianpopcon" . "https://qa.debian.org/popcon.php?package=") ("ebay" . "https://www.ebay.com/sch/i.html?_nkw=") ("fedoraforums" . "https://www.google.com/search?nfpr=1&num=100&q=site:ask.fedoraproject.org+|+site:discussion.fedoraproject.org+|+site:lists.fedoraproject.org+|+site:forums.fedoraforum.org+|+site:www.reddit.com/r/Fedora+") ("ebayprice" . "https://www.ebay.com/sch/i.html?_sop=15&_nkw=") ("emacsforums" . "https://www.google.com/search?nfpr=1&num=100&q=site:www.reddit.com/r/emacs+|+site:emacs.stackexchange.com+|+site:forum.systemcrafters.net+") ("emacsmailinglists" . "https://www.google.com/search?nfpr=1&num=100&q=site:lists.gnu.org/archive/html/help-gnu-emacs+|+site:lists.gnu.org/archive/html/emacs+") ("english" . "https://www.google.com/search?nfpr=1&num=100&q=\"English\"+|+\"grammar\"+") ("etsy" . "https://www.etsy.com/search?q=") ("ewg" . "https://www.ewg.org/skindeep/search/?search=") ("fdroid" . "https://search.f-droid.org/?q=") ("fedorapackages" . "https://packages.fedoraproject.org/search?query=") ("flashlightforums" . "https://www.google.com/search?nfpr=1&num=100&q=site:budgetlightforum.com+|+site:candlepowerforums.com+|+site:www.reddit.com/r/flashlight+") ("firefoxaddons" . "https://addons.mozilla.org/en-US/firefox/search/?type=extension&q=") ("footguns" . "https://www.google.com/search?nfpr=1&num=100&q=\"footgun\"+|+\"footguns\"+|+\"mistake\"+|+\"mistakes\"+") ("github" . "https://github.com/search?type=Repositories&s=stars&q=") ("githubcode" . "https://github.com/search?type=code&auto_enroll=true&q=") ("githubgoogle" . "https://www.google.com/search?nfpr=1&num=100&q=site:github.com+") ("githublanguage" . "https://github.com/search?q=stars%3A%3E1&s=stars&l=") ("goodreads" . "https://www.goodreads.com/search?q=") ("google" . "https://www.google.com/search?nfpr=1&num=100&q=") ("googlebooks" . "https://www.google.com/search?nfpr=1&num=100&tbm=bks&q=") ("googleimages" . "https://www.google.com/search?nfpr=1&num=100&tbm=isch&q=") ("googlemaps" . "https://www.google.com/maps/search/") ("googleshopping" . "https://www.google.com/search?nfpr=1&udm=28&q=") ("googleplay" . "https://play.google.com/store/search?c=apps&q=") ("googleyear" . "https://www.google.com/search?nfpr=1&num=100&tbs=qdr:y&q=") ("hn" . "https://hn.algolia.com/?type=all&sort=byDate&query=") ("hntitles" . "https://hn.algolia.com/?type=story&query=") ("homedepot" . "https://www.homedepot.com/s/") ("indeed" . "https://www.indeed.com/jobs?l=Remote&q=") ("leanpub" . "https://leanpub.com/bookstore?search=") ("linkedin" . "https://www.linkedin.com/jobs/search/?f_WT=2&keywords=") ("lobsters" . "https://lobste.rs/search?what=comments&q=") ("lobsterstitles" . "https://lobste.rs/search?what=stories&order=relevance&q=") ("lowes" . "http://www.lowes.com/search?searchTerm=") ("lwn" . "https://www.google.com/search?nfpr=1&num=100&q=site:lwn.net+") ("mdn" . "https://www.google.com/search?nfpr=1&num=100&q=site:developer.mozilla.org/en+") ("melpa" . "https://melpa.org/#/?sort=downloads&asc=false&q=") ("npm" . "https://www.npmjs.com/search?q=") ("onelook" . "https://www.onelook.com/?w=") ("opensusesoftware" . "https://software.opensuse.org/search?baseproject=openSUSE:Factory&q=") ("oreilly" . "https://www.oreilly.com/search/?formats=book&rows=100&query=") ("pkgs" . "https://pkgs.org/search/?q=") ("pypi" . "https://pypi.org/search/?q=") ("reddit" . "https://www.reddit.com/search/?t=year&q=") ("redditgoogle" . "https://www.google.com/search?nfpr=1&num=100&q=site:www.reddit.com+") ("repology" . "https://repology.org/projects/?search=") ("slickdeals" . "https://slickdeals.net/newsearch.php?rating=1&sort=newest&q=") ("target" . "https://www.target.com/s?searchTerm=") ("walgreens" . "https://www.walgreens.com/search/results.jsp?Ntt=") ("walmart" . "https://www.walmart.com/search?query=") ("walmartpetrx" . "https://www.walmartpetrx.com/search.aspx?SearchTerm=") ("wikipedia" . "https://www.google.com/search?nfpr=1&num=100&q=site:en.wikipedia.org+") ("youtube" . "https://www.youtube.com/results?search_query="))) (add-to-list 'org-file-apps '("\\.pdf\\'" . "evince %s")) (add-hook 'org-mode-hook (defun my-org-mode-hook-settings () (setq comment-start nil) (add-to-list 'fill-nobreak-predicate #'my-org-fill-nobreak-p) (auto-fill-mode 1) (electric-indent-local-mode -1) (add-hook 'before-save-hook #'my-org-list-renumber nil "LOCAL") (add-hook 'before-save-hook #'my-org-table-recalculate nil "LOCAL") (add-hook 'before-save-hook #'org-footnote-normalize nil "LOCAL") ;; Run `org-fill-paragraph' after `org-footnote-normalize', ;; not before, or else footnotes may wrap unnecessarily. (add-hook 'before-save-hook #'org-fill-paragraph nil "LOCAL") (add-hook 'after-save-hook #'my-org-export-html-on-save nil "LOCAL"))) (defun my-org-at-table-header-p () "Return non-nil if the cursor is inside a table header." (when (org-at-table-p) (or (save-excursion (forward-line -1) (not (org-at-table-p))) (save-excursion (forward-line) (org-at-table-hline-p))))) (defvar my-org-enable-export-html-on-save nil) (defun my-org-export-html-on-save () "Export current buffer to HTML on save. The `my-org-enable-export-html-on-save' variable must set to true (e.g., in .dir-locals.el)." (when (eq my-org-enable-export-html-on-save t) (org-html-export-to-html))) (defun my-org-fill-nobreak-p () "Don't break a line in the following situations: in a bracketed link, at the beginning of a list item that starts with a bracketed link, or in raw inline HTML." (or (looking-back "\\[\\[[^]]+\\]\\[[^]]+" nil) ; Link. (looking-back "^[ ]*[-+][ []+" nil) ; Unordered list item. (looking-back "^[ ]*[0-9]+[.) []+" nil) ; Ordered list item. (looking-back "@@html:[^@]+" nil))) ; Raw inline HTML. (defun my-org-insert-line-break () "Insert '\\' at the end of the current line to enforce a line break. https://orgmode.org/manual/Paragraphs.html" (interactive) (move-end-of-line nil) (insert "\\\\")) (defun my-org-list-renumber () "Renumber the current list." (when (and (org-at-item-p) (not (org-at-item-checkbox-p))) (save-excursion (org-beginning-of-item-list) (org-ctrl-c-ctrl-c)))) (defun my-org-table-recalculate () "Recalculate the current table line. If the line is a table header line, don't recalculate the line; only align the table." (when (org-at-table-p) (if (my-org-at-table-header-p) (org-table-align) (org-table-recalculate)))) (defalias 'my-org-export #'org-export-dispatch) (defalias 'my-org-footnote-new #'org-footnote-new) (defalias 'my-org-sort-list #'org-sort-list) (defalias 'my-org-table-insert-hline #'org-table-insert-hline) (defalias 'my-org-table-sort-lines #'org-table-sort-lines) (defalias 'my-org-table-sum #'org-table-sum) (put 'my-org-enable-export-html-on-save 'safe-local-variable #'booleanp) (put 'org-html-head 'safe-local-variable #'stringp) (provide 'init-org) ;;; init-org.el ends here