;;; my-settings.el --- Summary -*- lexical-binding: t -*- ;;; Commentary: ;;; Code: (use-package my :init ;; (load-file (concat config-dir "lisp/my/my-autoloads.el")) (require 'my-autoloads) :config (with-eval-after-load 'org (add-hook 'org-mode-hook 'my-org-link-color-hook) (add-hook 'org-ctrl-c-ctrl-c-hook 'my-org-table-cell-color-attr))) (use-package olivetti :commands (olivetti-mode) :bind (("" . my-distraction-free)) :config (defun my-distraction-free () "Distraction-free writing environment." (interactive) (if (equal olivetti-mode nil) (progn (window-configuration-to-register 1) (delete-other-windows) (when (equal major-mode 'org-mode) (when (and (featurep 'org-superstar) (equal org-superstar-mode t)) ;; remove leading stars (setq my-last-org-hide-leading-stars org-hide-leading-stars) (setq org-hide-leading-stars nil) ;; must be nil! hiding via `org-superstar-remove-leading-stars' (setq my-last-org-superstar-remove-leading-stars org-superstar-remove-leading-stars) (setq org-superstar-remove-leading-stars t) (org-superstar-restart)) (unless (and (featurep 'org-num) org-num-mode) (setq my-last-org-num-mode (when (featurep 'org-num) org-num-mode)) (org-num-mode))) (olivetti-mode t)) (progn (jump-to-register 1) ;; reset to last state (when (equal major-mode 'org-mode) (when (and (featurep 'org-superstar) (equal org-superstar-mode t)) (setq org-hide-leading-stars my-last-org-hide-leading-stars) (setq org-superstar-remove-leading-stars my-last-org-superstar-remove-leading-stars) (org-superstar-restart)) (unless my-last-org-num-mode (org-num-mode -1))) (olivetti-mode 0))))) (use-package my-org-article :demand :after (org) :bind (:map org-mode-map ("" . my-org-article-html-export-to-html-notify-async) ("" . my-org-article-latex-export-to-pdf-notify-async)) :config ;; HTML (defun my-org-article-html-export-to-html-notify (&optional async subtreep visible-only body-only ext-plist) "HTML article export. Extended `my-org-article-html-export-to-html' with an additional notification." (interactive) (let* ((extension (concat (when (> (length org-html-extension) 0) ".") (or (plist-get ext-plist :html-extension) org-html-extension "html"))) (file (org-export-output-file-name extension subtreep)) ;; need to bind this because tufte treats footnotes specially, so we ;; don't want to display them at the bottom (org-html-footnotes-section (if org-tufte-include-footnotes-at-bottom org-html-footnotes-section ""))) (org-export-to-file 'article-html file async subtreep visible-only body-only ext-plist (lambda (file) ;; is called with FILE and has to return a file name. (progn (when my-dbusp (use-package notifications) (notifications-notify :title "Emacs Org Article HTML Export" :body "Export done." :timeout 60000 :urgency 'normal :category "transfer")) file))))) ;; is needed for the asynchronous task (defun my-org-article-html-export-to-html-notify-async () "HTML article async export. Run `my-org-article-html-export-to-html' async and kill gnuplot buffer. See also async init file `org-export-async-init-file'." (interactive) (save-buffer) (when (get-buffer "*gnuplot*") (kill-buffer "*gnuplot*")) ;; to get a new session (my-org-article-html-export-to-html-notify t)) ;; LaTeX (defun my-org-article-latex-export-to-pdf-notify (&optional async subtreep visible-only body-only ext-plist) "LaTeX article export. Extended `my-org-article-latex-export-to-pdf' with an additional notification." (interactive) (let ((outfile (org-export-output-file-name ".tex" subtreep))) (org-export-to-file 'article-latex outfile async subtreep visible-only body-only ext-plist (lambda (file) ;; is called with FILE and has to return a file name. (let ((output (org-latex-compile file))) (when my-dbusp (use-package notifications) (notifications-notify :title "Emacs Org Article Latex Export to PDF" :body "Export done." :timeout 60000 :urgency 'normal :category "transfer")) output))))) ;; is needed for the asynchronous task (defun my-org-article-latex-export-to-pdf-notify-async () "LaTeX article async export. Run `my-org-article-latex-export-to-pdf-notify' async and kill gnuplot buffer. See also async init file `org-export-async-init-file'." (interactive) (save-buffer) (when (get-buffer "*gnuplot*") (kill-buffer "*gnuplot*")) ;; to get a new session (my-org-article-latex-export-to-pdf-notify t)) ) (use-package my-org-letter :after (org)) (provide 'my-settings) ;;; my-settings.el ends here