mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-24 03:50:24 +10:00
Moving to Doom Emacs!
This commit is contained in:
60
.emacs.d/modules/lang/org/contrib/dragndrop.el
Normal file
60
.emacs.d/modules/lang/org/contrib/dragndrop.el
Normal file
@@ -0,0 +1,60 @@
|
||||
;;; lang/org/contrib/dragndrop.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +dragndrop)
|
||||
|
||||
(use-package! org-download
|
||||
:commands org-download-dnd org-download-dnd-base64
|
||||
:init
|
||||
;; HACK We add these manually so that org-download is truly lazy-loaded
|
||||
(pushnew! dnd-protocol-alist
|
||||
'("^\\(?:https?\\|ftp\\|file\\|nfs\\):" . +org-dragndrop-download-dnd-fn)
|
||||
'("^data:" . org-download-dnd-base64))
|
||||
(advice-add #'org-download-enable :override #'ignore)
|
||||
:config
|
||||
(setq org-download-image-dir org-attach-directory
|
||||
org-download-heading-lvl nil
|
||||
org-download-timestamp "_%Y%m%d_%H%M%S"
|
||||
org-download-screenshot-method
|
||||
(cond (IS-MAC "screencapture -i %s")
|
||||
(IS-LINUX
|
||||
(cond ((executable-find "maim") "maim -s %s")
|
||||
((executable-find "scrot") "scrot -s %s")))))
|
||||
|
||||
;; Handle non-image files a little differently. Images should be inserted
|
||||
;; as-is, as image previews. Other files, like pdfs or zips, should be linked
|
||||
;; to, with an icon indicating the type of file.
|
||||
(defadvice! +org--dragndrop-insert-link-a (_link filename)
|
||||
"Produces and inserts a link to FILENAME into the document.
|
||||
|
||||
If FILENAME is an image, produce an attach:%s path, otherwise use file:%s (with
|
||||
an file icon produced by `+org-attach-icon-for')."
|
||||
:override #'org-download-insert-link
|
||||
(if (looking-back "^[ \t]+" (line-beginning-position))
|
||||
(delete-region (match-beginning 0) (match-end 0))
|
||||
(newline))
|
||||
(cond ((image-type-from-file-name filename)
|
||||
(insert
|
||||
(concat (if (= org-download-image-html-width 0) ""
|
||||
(format "#+attr_html: :width %dpx\n" org-download-image-html-width))
|
||||
(if (= org-download-image-latex-width 0) ""
|
||||
(format "#+attr_latex: :width %dcm\n" org-download-image-latex-width))
|
||||
(cond ((file-in-directory-p filename org-attach-directory)
|
||||
(format "[[attach:%s]]" (file-relative-name filename org-attach-directory)))
|
||||
((file-in-directory-p filename org-directory)
|
||||
(format org-download-link-format (file-relative-name filename org-directory)))
|
||||
((format org-download-link-format filename)))))
|
||||
(org-display-inline-images))
|
||||
((insert
|
||||
(format "%s [[./%s][%s]] "
|
||||
(+org-attach-icon-for filename)
|
||||
(file-relative-name filename (file-name-directory buffer-file-name))
|
||||
(file-name-nondirectory (directory-file-name filename)))))))
|
||||
|
||||
(advice-add #'org-download--dir-2 :override #'ignore)
|
||||
(defadvice! +org--dragndrop-download-fullname-a (path)
|
||||
"Write PATH relative to current file."
|
||||
:filter-return #'org-download--fullname
|
||||
(let ((dir (or (if buffer-file-name (file-name-directory buffer-file-name))
|
||||
default-directory)))
|
||||
(if (file-in-directory-p dir org-directory)
|
||||
(file-relative-name path dir)
|
||||
path))))
|
||||
41
.emacs.d/modules/lang/org/contrib/ipython.el
Normal file
41
.emacs.d/modules/lang/org/contrib/ipython.el
Normal file
@@ -0,0 +1,41 @@
|
||||
;;; lang/org/contrib/babel.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +ipython)
|
||||
|
||||
(use-package! ob-ipython
|
||||
:defer t
|
||||
:init
|
||||
(defvar +ob-ipython-local-runtime-dir nil)
|
||||
|
||||
(setq ob-ipython-resources-dir ".ob-ipython-resrc")
|
||||
|
||||
(add-hook! '+org-babel-load-functions
|
||||
(defun +org-babel-load-ipython-h (lang)
|
||||
(and (string-prefix-p "jupyter-" (symbol-name lang))
|
||||
(require 'ob-ipython nil t))))
|
||||
|
||||
(after! org-src
|
||||
(add-to-list 'org-src-lang-modes '("ipython" . python)))
|
||||
(after! ox-latex
|
||||
(add-to-list 'org-latex-minted-langs '(ipython "python")))
|
||||
:config
|
||||
(set-popup-rules!
|
||||
'(("\\*ob-ipython.*"
|
||||
:slot 2 :side right :size 100 :height 0.2
|
||||
:select nil :quit nil :ttl nil)
|
||||
("^ \\*Python"
|
||||
:slot 0 :side right :size 100
|
||||
:select nil :quit nil :ttl nil)))
|
||||
|
||||
;; advices for remote kernel and org-src-edit
|
||||
(advice-add #'ob-ipython--create-repl :override #'+org-ob-ipython-create-repl-a)
|
||||
(advice-add #'org-babel-edit-prep:ipython :override #'+org-babel-edit-prep:ipython-a)
|
||||
(advice-add #'org-babel-execute:ipython :before #'+org-babel-execute:ipython-a)
|
||||
(advice-add #'org-babel-ipython-initiate-session :override #'+org-ob-ipython-initiate-session-a)
|
||||
|
||||
;; retina resolution image hack
|
||||
(when IS-MAC
|
||||
(advice-add #'ob-ipython--write-base64-string :around #'+org-ob-ipython-write-base64-string-a))
|
||||
|
||||
;; ipython has its own async keyword, disable ipython in ob-async.
|
||||
(after! ob-async
|
||||
(add-to-list 'ob-async-no-async-languages-alist "ipython")))
|
||||
16
.emacs.d/modules/lang/org/contrib/journal.el
Normal file
16
.emacs.d/modules/lang/org/contrib/journal.el
Normal file
@@ -0,0 +1,16 @@
|
||||
;;; lang/org/contrib/journal.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +journal)
|
||||
|
||||
(after! org-journal
|
||||
(setq org-journal-dir (expand-file-name "journal/" org-directory)
|
||||
org-journal-file-pattern
|
||||
(expand-file-name "\\(?1:[0-9]\\{4\\}\\)\\(?2:[0-9][0-9]\\)\\(?3:[0-9][0-9]\\)\\'"
|
||||
org-journal-dir))
|
||||
|
||||
(map! :localleader
|
||||
(:map org-journal-search-mode-map
|
||||
"n" #'org-journal-search-next
|
||||
"p" #'org-journal-search-prev)
|
||||
(:map org-journal-mode-map
|
||||
"n" #'org-journal-open-next-entry
|
||||
"p" #'org-journal-open-previous-entry)))
|
||||
15
.emacs.d/modules/lang/org/contrib/pomodoro.el
Normal file
15
.emacs.d/modules/lang/org/contrib/pomodoro.el
Normal file
@@ -0,0 +1,15 @@
|
||||
;;; lang/org/contrib/pomodoro.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +pomodoro)
|
||||
|
||||
(after! org-pomodoro
|
||||
;; prefer PulseAudio to ALSA in $current_year
|
||||
(setq org-pomodoro-audio-player (or (executable-find "paplay")
|
||||
org-pomodoro-audio-player))
|
||||
|
||||
;; configure pomodoro alerts to use growl or libnotify
|
||||
(alert-add-rule :category "org-pomodoro"
|
||||
:style (cond (alert-growl-command
|
||||
'growl)
|
||||
(alert-libnotify-command
|
||||
'libnotify)
|
||||
(alert-default-style))))
|
||||
54
.emacs.d/modules/lang/org/contrib/present.el
Normal file
54
.emacs.d/modules/lang/org/contrib/present.el
Normal file
@@ -0,0 +1,54 @@
|
||||
;;; lang/org/contrib/present.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +present)
|
||||
|
||||
(defvar +org-present-text-scale 7
|
||||
"The `text-scale-amount' for `org-tree-slide-mode'.")
|
||||
|
||||
(after! ox
|
||||
(add-to-list 'org-export-backends 'beamer))
|
||||
|
||||
|
||||
;;
|
||||
;;; Packages
|
||||
|
||||
(use-package! org-re-reveal
|
||||
:after ox
|
||||
:init
|
||||
(setq org-re-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js@3/"))
|
||||
|
||||
|
||||
(use-package! org-tree-slide
|
||||
:commands org-tree-slide-mode
|
||||
:config
|
||||
(org-tree-slide-simple-profile)
|
||||
(setq org-tree-slide-skip-outline-level 2
|
||||
org-tree-slide-activate-message " "
|
||||
org-tree-slide-deactivate-message " "
|
||||
org-tree-slide-modeline-display nil)
|
||||
|
||||
(map! :map org-tree-slide-mode-map
|
||||
:n [right] #'org-tree-slide-move-next-tree
|
||||
:n [left] #'org-tree-slide-move-previous-tree)
|
||||
|
||||
(add-hook! 'org-tree-slide-mode-after-narrow-hook
|
||||
#'+org-present-detect-slide-h
|
||||
#'+org-present-add-overlays-h
|
||||
#'org-display-inline-images)
|
||||
|
||||
(add-hook 'org-tree-slide-mode-hook #'+org-present-init-org-tree-window-h)
|
||||
|
||||
(defadvice! +org-present--narrow-to-subtree-a (orig-fn &rest args)
|
||||
"Narrow to the target subtree when you start the presentation."
|
||||
:around #'org-tree-slide--display-tree-with-narrow
|
||||
(cl-letf (((symbol-function #'org-narrow-to-subtree)
|
||||
(lambda () (save-excursion
|
||||
(save-match-data
|
||||
(org-with-limited-levels
|
||||
(narrow-to-region
|
||||
(progn (org-back-to-heading t)
|
||||
(forward-line 1)
|
||||
(point))
|
||||
(progn (org-end-of-subtree t t)
|
||||
(when (and (org-at-heading-p) (not (eobp))) (backward-char 1))
|
||||
(point)))))))))
|
||||
(apply orig-fn args))))
|
||||
Reference in New Issue
Block a user