Remove org-mode config (I no longer use org-mode)

This commit is contained in:
Henrik Lissner 2016-02-26 00:02:37 -05:00
parent 8d09932cc6
commit fea2a2ce4a
10 changed files with 0 additions and 1382 deletions

View file

@ -88,12 +88,5 @@ buffers."
(helm-buffers-list)) (helm-buffers-list))
(helm-buffers-list))) (helm-buffers-list)))
;;;###autoload
(defun narf/helm-org-find-files ()
(interactive)
(in! org-directory
(let ((helm-ff-skip-boring-files t))
(helm-find-files-1 (concat org-directory "/")))))
(provide 'defuns-helm) (provide 'defuns-helm)
;;; defuns-helm.el ends here ;;; defuns-helm.el ends here

View file

@ -41,12 +41,6 @@
(let ((default-directory (narf/project-root))) (let ((default-directory (narf/project-root)))
(ido-find-file))) (ido-find-file)))
;;;###autoload
(defun narf/ido-find-org-file ()
(interactive)
(let ((default-directory org-directory))
(ido-find-file)))
;;;###autoload ;;;###autoload
(defun narf/ido-recentf () (defun narf/ido-recentf ()
"Use `ido-completing-read' to \\[find-file] a recent file" "Use `ido-completing-read' to \\[find-file] a recent file"

View file

@ -89,10 +89,6 @@
;;module-nim ; look out Abraham ;;module-nim ; look out Abraham
;;module-pony ; Dear Princess Compiler ;;module-pony ; Dear Princess Compiler
;; Organizational/Writing
;;module-write ; making Emacs fit for writing fiction, papers & notes
;;module-org ; for fearless [and organized] leader
;; Extra Tools ;; Extra Tools
module-demo ; allow me to demonstrate... module-demo ; allow me to demonstrate...

View file

@ -1,86 +0,0 @@
;;; defuns-org-attach.el --- custom attachment system
;; I know Org has its own attachment system, but I don't like it.
;;;###autoload (autoload 'narf:org-attach "defuns-org-attach" nil t)
(evil-define-command narf:org-attach (&optional bang link)
(interactive "<!><a>")
(if (not link)
(narf:org-attachment-list bang)
(require 'org-download)
(let ((new-path (if bang
(format "%s/%s" (expand-file-name org-download-image-dir org-directory)
(format "%s%s.%s"
(f-base link)
(format-time-string org-download-timestamp)
(file-name-extension link))) buffer-file-name
(org-download--fullname link))))
(unless new-path
(user-error "No file was provided"))
(cond ((string-match-p "^https?://" link)
(url-copy-file link new-path))
(t (copy-file link new-path)))
(let ((relpath (f-relative new-path default-directory)))
(if (evil-visual-state-p)
(org-insert-link nil (format "./%s" relpath) (buffer-substring-no-properties (region-beginning) (region-end)))
(insert (format "[[./%s]]" relpath)))))))
;;;###autoload (autoload 'narf:org-attachment-list "defuns-org-attach" nil t)
(evil-define-command narf:org-attachment-list (&optional bang)
(interactive "<!>")
(if bang
(narf:org-attachment-cleanup)
(let ((attachments (narf-org--get-attachments)))
(unless attachments
(user-error "No attachments in this file"))
(helm :sources
(helm-build-sync-source "Attachments"
:candidates attachments
:real-to-display 'narf-org--attachment-real-to-display
:action '(("Go to Attachment in Buffer" . narf-org--attachment-find)
("Reveal Attachment in Finder" . narf-org--attachment-reveal)
("Open Attachment" . narf-org--attachment-open)
("Delete Attachment" . narf-org--attachment-delete)))))))
;; TODO Improve
;;;###autoload
(defun narf/org-attachment-reveal ()
(interactive)
(let ((context (org-element-context)))
(narf-open-with
nil
(if (and context (eq (org-element-type context) 'link))
(f-dirname (org-element-property :path context))
org-download-image-dir))))
(defun narf-org--get-attachments ()
(org-element-map (org-element-parse-buffer) 'link
(lambda (link)
(when (and (string= (org-element-property :type link) "file")
(string-prefix-p (format "./%s" org-download-image-dir)
(org-element-property :path link)))
(org-element-property :path link)))))
(defun narf-org--attachment-real-to-display (real)
(propertize (f-filename real) 'face (if (file-exists-p real) 'helm-ff-file 'shadow)))
(defun narf-org--attachment-find (file)
(search-forward-regexp (format "[[\\(file:\\)?%s]]" file) nil t)
(ignore-errors
(save-excursion
(outline-previous-visible-heading 1)
(org-show-subtree))))
(defun narf-org--attachment-reveal (file)
(narf-open-with nil (f-dirname file)))
(defun narf-org--attachment-open (file)
(narf-open-with nil file))
(defun narf-org--attachment-delete (file)
(delete-file file)
(narf-org--attachment-find file)
(message "File deleted, now delete the link! (%s)" file))
(provide 'defuns-org-attach)
;;; defuns-org-attach.el ends here

View file

@ -1,115 +0,0 @@
;;; defuns-org-crm.el --- for my custom org-based CRM
(require 'helm-deft)
(defun narf--helm-org (&optional directory)
(let ((helm-deft-dir-list `(,(or directory default-directory))))
(helm-deft)))
;;;###autoload
(defun narf/helm-org ()
(interactive)
(narf--helm-org org-directory))
;;;###autoload
(defun narf/helm-org-crm-projects ()
(interactive)
(narf--helm-org org-directory-projects))
;;;###autoload
(defun narf/helm-org-crm-contacts ()
(interactive)
(narf--helm-org org-directory-contacts))
;;;###autoload
(defun narf/helm-org-crm-invoices ()
(interactive)
(narf--helm-org org-directory-invoices))
;;;###autoload
(defun narf/helm-org-writing ()
(interactive)
(let ((narf--helm-org-params '()))
(narf--helm-org (expand-file-name "writing/" org-directory))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun narf--org-crm-assert-type (type)
(unless (memq type '(project contact invoice))
(user-error "Not a valid type: %s" type)))
(defun narf--org-crm-new-path (name type)
(narf--org-crm-assert-type type)
(let* ((prefix
(replace-regexp-in-string
"/+$" "" (symbol-value (intern (format "org-directory-%ss" type)))))
(last-file (car-safe (sort (f-glob "*.org" prefix) 'org-string>))))
(when last-file
(let* ((old-id (narf--org-crm-path-to-id last-file type))
(new-id (format "%04X" (1+ old-id))))
(if (eq type 'invoice)
(format "%s/%s-%s.org" prefix (format-time-string "%y%m") new-id)
(format "%s/%s-%s.org" prefix
new-id (replace-regexp-in-string "[][ !@#$%^&*()]" "-" name)))))))
(defun narf--org-crm-path-to-id (path type)
(narf--org-crm-assert-type type)
(let ((base (f-filename path)))
(string-to-number
(if (eq type 'invoice)
(substring base (1+ (string-match-p "-" base)) (string-match-p ".org" base))
(substring base 0 (string-match-p "[-.]" base)))
16)))
(defun narf--org-crm-id-to-path (id type)
(narf--org-crm-assert-type type)
(let* ((prefix
(replace-regexp-in-string
"/+$" "" (symbol-value (intern (format "org-directory-%ss" type))))))
(car-safe
(f-glob (format (cond ((eq type 'invoice)
"*-%04X.org")
((eq type 'courses)
"%s*.org")
(t
"%04X*.org"))
(string-to-number id 16))
prefix))))
(defun narf--org-crm (&optional id type new-p)
(let ((file (if new-p
(or (narf--org-crm-new-path id type)
(user-error "path could not be resolved: type(%s) name(%s)" type name))
(or (narf--org-crm-id-to-path id type)
(user-error "id %s could not be resolved in %s" id type))))
(old-buffer (current-buffer)))
(find-file file)
(with-current-buffer old-buffer
(when (evil-visual-state-p)
(org-insert-link
nil (format "%s:%s" (symbol-name type) (narf--org-crm-path-to-id file type))
(buffer-substring-no-properties (region-beginning) (region-end)))))))
;;;###autoload (autoload 'narf:org-crm-project "defuns-org-crm" nil t)
(evil-define-command narf:org-crm-project (&optional bang name)
(interactive "<!><a>")
(if bang
(narf--org-crm name 'project t)
(narf/helm-org-crm-projects)))
;;;###autoload (autoload 'narf:org-crm-contact "defuns-org-crm" nil t)
(evil-define-command narf:org-crm-contact (&optional bang name)
(interactive "<!><a>")
(if bang
(narf--org-crm name 'contact t)
(narf/helm-org-crm-contacts)))
;;;###autoload (autoload 'narf:org-crm-invoice "defuns-org-crm" nil t)
(evil-define-command narf:org-crm-invoice (&optional bang)
(interactive "<!>")
(if bang
(narf--org-crm nil 'invoice t)
(narf/helm-org-crm-invoices)))
(provide 'defuns-org-crm)
;;; defuns-org-crm.el ends here

View file

@ -1,306 +0,0 @@
;;; defuns-org.el
;;;###autoload
(defun narf/org-get-property (name)
(interactive)
(save-excursion
(goto-char 1)
(re-search-forward (format "^#\\+%s:[ \t]*\\([^\n]+\\)" (upcase name)) nil t)
(buffer-substring-no-properties (match-beginning 1) (match-end 1))))
;;;###autoload
(defun narf/org-open-notes ()
(interactive)
(find-file org-default-notes-file))
;;;###autoload
(defun narf/org-open-todo ()
(interactive)
(find-file org-default-todo-file))
;;;###autoload
(defun narf/org-insert-item (direction)
"Inserts a new heading or item, depending on the context."
(interactive)
(let* ((context (org-element-context)
;; (org-element-lineage
;; '(table table-row headline inlinetask
;; item plain-list)
;; t)
)
(type (org-element-type context)))
(cond ((eq type 'item)
(cl-case direction
('below
(org-end-of-line)
(org-insert-heading))
('above
(evil-first-non-blank)
(org-insert-heading)))
(when (org-element-property :checkbox context)
(insert "[ ] ")))
((memq type '(table table-row))
(cl-case direction
('below
(org-table-insert-row))
('above
(narf/org-table-prepend-row-or-shift-up))))
(t
(cl-case direction
('below
(org-insert-heading-after-current))
('above
(org-back-to-heading)
(org-insert-heading)))
(when (org-element-property :todo-type context)
(org-todo 'todo))))
(evil-append-line 1)))
;;;###autoload
(defun narf/org-toggle-checkbox ()
(interactive)
(let ((context (org-element-lineage (org-element-context) '(item) t)))
(when context
(org-end-of-line)
(org-beginning-of-line)
(if (org-element-property :checkbox context)
(when (search-backward-regexp "\\[[ +-]\\]" (line-beginning-position) t)
(delete-char 4))
(insert "[ ] ")))))
;;;###autoload
(defun narf/org-dwim-at-point ()
(interactive)
(let* ((scroll-pt (window-start))
(context (org-element-context))
(type (org-element-type context))
(value (org-element-property :value context)))
(cond
((memq type '(table table-row))
(if (org-element-property :tblfm (org-element-property :parent context))
(org-table-recalculate t)
(org-table-align)))
((and (memq type '(item))
(org-element-property :checkbox context))
(org-toggle-checkbox))
((and (memq type '(headline))
(org-element-property :todo-type context))
(org-todo
(if (eq (org-element-property :todo-type context) 'done) 'todo 'done)))
((memq type '(headline))
(org-remove-latex-fragment-image-overlays)
(org-preview-latex-fragment '(4)))
((memq type '(babel-call))
(org-babel-lob-execute-maybe))
((memq type '(src-block inline-src-block))
(org-babel-execute-src-block))
((memq type '(latex-fragment latex-environment))
(org-preview-latex-fragment))
((memq type '(link))
(org-open-at-point))
(t (narf/org-refresh-inline-images)))
(set-window-start nil scroll-pt)))
;;;###autoload
(defun narf/org-refresh-inline-images ()
(interactive)
(if (> (length org-inline-image-overlays) 0)
(org-remove-inline-images)
(org-display-inline-images
nil t
(save-excursion (org-back-to-heading) (point))
(save-excursion (org-end-of-subtree) (point)))))
;; Formatting shortcuts
;;;###autoload
(defun narf/org-surround (delim)
(if (region-active-p)
(save-excursion
(goto-char (region-beginning))
(insert delim)
(goto-char (region-end))
(insert delim))
(insert delim)
(save-excursion (insert delim))))
;;;###autoload
(defun narf/org-word-count (beg end &optional count-footnotes?)
"Report the number of words in the Org mode buffer or selected region.
Ignores:
- comments
- tables
- source code blocks (#+BEGIN_SRC ... #+END_SRC, and inline blocks)
- hyperlinks (but does count words in hyperlink descriptions)
- tags, priorities, and TODO keywords in headers
- sections tagged as 'not for export'.
The text of footnote definitions is ignored, unless the optional argument
COUNT-FOOTNOTES? is non-nil."
(interactive "r")
(unless mark-active
(setf beg (point-min)
end (point-max)))
(let ((wc 0))
(save-excursion
(goto-char beg)
(while (< (point) end)
(cond
;; Ignore comments.
((or (org-at-comment-p) (org-at-table-p))
nil)
;; Ignore hyperlinks. But if link has a description, count
;; the words within the description.
((looking-at org-bracket-link-analytic-regexp)
(when (match-string-no-properties 5)
(let ((desc (match-string-no-properties 5)))
(save-match-data
(incf wc (length (remove "" (org-split-string
desc "\\W")))))))
(goto-char (match-end 0)))
((looking-at org-any-link-re)
(goto-char (match-end 0)))
;; Ignore source code blocks.
((org-between-regexps-p "^#\\+BEGIN_SRC\\W" "^#\\+END_SRC\\W")
nil)
;; Ignore inline source blocks, counting them as 1 word.
((save-excursion
(backward-char)
(looking-at org-babel-inline-src-block-regexp))
(goto-char (match-end 0))
(setf wc (+ 2 wc)))
;; Ignore footnotes.
((and (not count-footnotes?)
(or (org-footnote-at-definition-p)
(org-footnote-at-reference-p)))
nil)
(t
(let ((contexts (org-context)))
(cond
;; Ignore tags and TODO keywords, etc.
((or (assoc :todo-keyword contexts)
(assoc :priority contexts)
(assoc :keyword contexts)
(assoc :checkbox contexts))
nil)
;; Ignore sections marked with tags that are
;; excluded from export.
((assoc :tags contexts)
(if (intersection (org-get-tags-at) org-export-exclude-tags
:test 'equal)
(org-forward-same-level 1)
nil))
(t
(incf wc))))))
(re-search-forward "\\w+\\W*")))
(message (format "%d words in %s." wc
(if mark-active "region" "buffer")))))
;;;###autoload (autoload 'narf:org-export "defuns-org" nil t)
(evil-define-command narf:org-export (dest)
(interactive "<a>")
(let ((path (if (string-match-p "^[/~]" dest)
dest
(expand-file-name dest default-directory))))
(if (shell-command
(format "/usr/local/bin/pandoc '%s' -o '%s'"
(buffer-file-name) path))
(message "Done! Exported to: %s" path)
(user-error "Export failed"))))
;;;###autoload
(defun narf/org-remove-link ()
"Replace an org link by its description or if empty its address"
(interactive)
(if (org-in-regexp org-bracket-link-regexp 1)
(let ((remove (list (match-beginning 0) (match-end 0)))
(description (if (match-end 3)
(org-match-string-no-properties 3)
(org-match-string-no-properties 1))))
(apply 'delete-region remove)
(insert description))))
;;;###autoload
(defun narf/org-table-next-row ()
(interactive)
(if (org-at-table-p) (org-table-next-row) (org-down-element)))
;;;###autoload
(defun narf/org-table-previous-row ()
(interactive)
(if (org-at-table-p) (narf--org-table-previous-row) (org-up-element)))
;;;###autoload
(defun narf/org-table-next-field ()
(interactive)
(if (org-at-table-p) (org-table-next-field) (org-end-of-line)))
;;;###autoload
(defun narf/org-table-previous-field ()
(interactive)
(if (org-at-table-p) (org-table-previous-field) (org-beginning-of-line)))
;;;###autoload
(defun narf/org-table-append-field-or-shift-right ()
(interactive)
(org-shiftmetaright)
(when (org-at-table-p) (org-metaright)))
;;;###autoload
(defun narf/org-table-prepend-field-or-shift-left ()
(interactive)
(if (org-at-table-p)
(org-shiftmetaright)
(org-shiftmetaleft)))
;;;###autoload
(defun narf/org-table-append-row-or-shift-down ()
(interactive)
(org-shiftmetadown)
(when (org-at-table-p) (org-metadown)))
;;;###autoload
(defun narf/org-table-prepend-row-or-shift-up ()
(interactive)
(if (org-at-table-p)
(org-shiftmetadown)
(org-shiftmetaup)))
(defun narf--org-table-previous-row ()
"Go to the previous row (same column) in the current table. Before doing so,
re-align the table if necessary. (Necessary because org-mode has a
`org-table-next-row', but not `org-table-previous-row')"
(interactive)
(org-table-maybe-eval-formula)
(org-table-maybe-recalculate-line)
(if (and org-table-automatic-realign
org-table-may-need-update)
(org-table-align))
(let ((col (org-table-current-column)))
(beginning-of-line 0)
(when (or (not (org-at-table-p)) (org-at-table-hline-p))
(beginning-of-line))
(org-table-goto-column col)
(skip-chars-backward "^|\n\r")
(when (org-looking-at-p " ") (forward-char))))
;;;###autoload
(defun narf/-org-capture-changelog ()
;; TODO
)
;;;###autoload
(defun narf/-org-capture-choose ()
;; TODO
)
(provide 'defuns-org)
;;; defuns-org.el ends here

View file

@ -1,45 +0,0 @@
;;; macros-org.el
;;;###autoload
(defmacro define-org-link! (type directory &optional id-func)
(setq directory (f-slash directory))
(let* ((type-str (symbol-name type))
(link-sym (intern (format "narf/org-link-%s" type-str)))
(dir-var (intern (format "org-directory-%s" type-str))))
`(progn
(defvar ,dir-var ,(expand-file-name directory org-directory))
(defun ,(intern (format "narf/helm-org-%s" type-str)) ()
(interactive)
(let ((default-directory ,directory))
(helm-deft)))
(defun ,link-sym (id)
(let ((path (f-glob (format "%s*.org" id) ,directory)))
(unless path
(error "ID not found: %s" id))
(org-open-file (car path) t)))
(org-add-link-type ,type-str ',link-sym)
(defun ,(intern (format "narf/org-%s-at-pt" type-str)) ()
(interactive)
(let* ((id (or (narf/org-get-property ,type-str)
(thing-at-point 'word t)))
(path (f-glob (format "%s*.org" id) ,dir-var)))
(unless path
(user-error "Couldn't find anything with %s (%s in %s)" id path ,directory))
(org-open-file (car path) t)))
(defun ,(intern (format "org-%s-complete-link" type-str)) ()
(let* ((default-directory (f-slash ,dir-var))
(file (org-iread-file-name ">>> "))
(relpath (f-relative file ,dir-var)))
(when (and (not (file-exists-p file))
(y-or-n-p (format "Create %s?" relpath)))
(write-region "" nil file)
(message "Created %s" file))
(format "%s:%s" ,type-str ,(if id-func `(funcall ,id-func relpath) 'relpath))
)))))
(provide 'macros-org)
;;; macros-org.el ends here

View file

@ -1,642 +0,0 @@
;;; module-org.el
(define-minor-mode evil-org-mode
"Evil-mode bindings for org-mode."
:init-value nil
:lighter "!"
:keymap (make-sparse-keymap) ; defines evil-org-mode-map
:group 'evil-org)
(defvar org-directory (expand-file-name write-mode-dir))
(defvar org-directory-contacts (expand-file-name "Work/Contacts/" org-directory))
(defvar org-directory-projects (expand-file-name "Work/Projects/" org-directory))
(defvar org-directory-invoices (expand-file-name "Work/Invoices/" org-directory))
(defvar org-directory-courses (expand-file-name "Courses/" org-directory))
(defvar org-default-notes-file (concat org-directory "/Notes.org"))
(add-hook! org-load 'narf|org-init)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun narf@org-vars ()
(setq org-agenda-files
(f-entries org-directory (lambda (path) (string-suffix-p ".org" path)))
org-archive-location (concat org-directory "/archive/%s::")
org-attach-directory ".attach/"
;; Use helm for refiling
org-completion-use-ido nil
org-refile-targets '((nil . (:maxlevel . 2)))
;; display full path in refile completion
org-refile-use-outline-path t
org-outline-path-complete-in-steps nil
org-default-priority ?C
org-catch-invisible-edits nil
org-confirm-elisp-link-function nil
org-hidden-keywords '(title)
org-special-ctrl-a/e t
org-hierarchical-todo-statistics t
org-checkbox-hierarchical-statistics nil
org-tags-column 0
org-loop-over-headlines-in-active-region t
org-footnote-auto-label 'plain
org-log-done t
org-agenda-window-setup 'other-window
org-agenda-skip-unavailable-files t
org-startup-folded t
org-todo-keywords '((sequence "TODO(t)" "|" "DONE(d)")
(sequence "IDEA(i)" "NEXT(n)" "ACTIVE(a)" "WAITING(w)" "LATER(l)" "|" "CANCELLED(c)")
(sequence "UNSENT(u)" "UNPAID(U)" "|" "PAID(p)"))
org-blank-before-new-entry '((heading . nil)
(plain-list-item . auto))
org-tag-alist '(("@home" . ?h)
("@daily" . ?d)
("@projects" . ?r))
org-capture-templates
'(("c" "Changelog" entry
(file+headline (concat (narf/project-root) "CHANGELOG.org") "Unreleased")
"* %?")
("j" "Journal" entry
(file+datetree (concat org-directory "journal.org"))
"** %<%H:%M>: %?\n%i" :prepend t)
("n" "Notes" entry
(file+headline org-default-notes-file "Inbox")
"* %u %?\n%i" :prepend t)
("v" "Vocab" entry
(file+headline (concat org-directory "topics/vocab.org") "Unsorted")
"** %i%?\n")
("e" "Excerpt" entry
(file+headline (concat org-directory "topics/excerpts.org") "Excerpts")
"** %u %?\n%i" :prepend t)
("q" "Quote" item
(file+headline (concat org-directory "topics/excerpts.org") "Quotes")
"+ %i\n *Source: ...*\n : @tags" :prepend t)
))
(defvar org-agenda-restore-windows-after-quit t)
(defvar org-agenda-custom-commands
'(("x" agenda)
("y" agenda*)
("l" todo "LEAD")
("t" todo)
("c" tags "+class")))
(let ((ext-regexp (regexp-opt '("GIF" "JPG" "JPEG" "SVG" "TIF" "TIFF" "BMP" "XPM"
"gif" "jpg" "jpeg" "svg" "tif" "tiff" "bmp" "xpm"))))
(setq iimage-mode-image-regex-alist
`((,(concat "\\(`?file://\\|\\[\\[\\|<\\|`\\)?\\([-+./_0-9a-zA-Z]+\\."
ext-regexp "\\)\\(\\]\\]\\|>\\|'\\)?") . 2)
(,(concat "<\\(http://.+\\." ext-regexp "\\)>") . 1))))
(add-to-list 'org-link-frame-setup '(file . find-file)))
(defun narf@org-export ()
(defvar narf-org-export-directory (concat org-directory ".export"))
(unless (featurep 'ox-opml)
(load-library "org-opml"))
(use-package ox-pandoc)
(setq org-export-backends '(ascii html latex md opml)
org-export-with-toc nil)
;; Export to a central directory (why isn't this easier?)
(defun narf*org-export-output-file-name (args)
(unless (nth 2 args)
(setq args (append args (list narf-org-export-directory))))
args)
(advice-add 'org-export-output-file-name :filter-args 'narf*org-export-output-file-name))
(defun narf@org-babel ()
(setq org-confirm-babel-evaluate nil ; you don't need my permission
org-src-window-setup 'current-window
org-src-fontify-natively t ; make code pretty
org-src-preserve-indentation t
org-src-tab-acts-natively t)
;; (defun narf-refresh-babel-lob ()
;; (let ((files (f-entries org-directory (lambda (path) (f-ext? path "org")) t)))
;; (async-start
;; `(lambda ()
;; ,(async-inject-variables "\\`\\(org-directory\\|load-path$\\)")
;; (require 'org)
;; (setq org-babel-library-of-babel nil)
;; (mapc (lambda (f) (org-babel-lob-ingest f)) (list ,@files))
;; org-babel-library-of-babel)
;; (lambda (lib)
;; ;; (persistent-soft-store 'org-babel-library lib "org")
;; (message "Library of babel updated!")
;; (setq org-babel-library-of-babel lib)))))
;; (setq org-babel-library-of-babel (narf-refresh-babel-lob))
(add-hook! org-mode
(add-hook 'after-save-hook
(lambda ()
(when (file-exists-p buffer-file-name)
(shut-up! (org-babel-lob-ingest buffer-file-name))))
t t)
;; Restore feedback on save
(add-hook 'after-save-hook (lambda () (message "Saved!")) t t))
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t) (ruby . t) (sh . t) (js . t) (css . t)
(plantuml . t) (emacs-lisp . t) (matlab . t)
(latex . t) (calc . t) (lisp . t) (lilypond . t)
(go . t)
(rust . t)))
;; (http . t)
(setq org-babel-lilypond-gen-png t)
;; Ensure lilypond doesn't print out entire pages for previews
(defvar org-babel-lilypond-prologue
"\\paper { indent = 0\\mm line-width = 180\\mm oddHeaderMarkup = \"\" evenHeaderMarkup = \"\" oddFooterMarkup = \"\" evenFooterMarkup = \"\" }")
(defun org-babel-lilypond-get-header-args (mode)
(cond (mode
`((:tangle . "yes")
(:noweb . "yes")
(:results . "silent")
(:cache . "yes")
(:comments . "yes")
(:prologue . ,org-babel-lilypond-prologue)))
(t
`((:results . "file")
(:exports . "results")
(:prologue . ,org-babel-lilypond-prologue)))))
(setq org-babel-default-header-args:lilypond
'((:results . "file")
(:exports . "results")
(:prologue . ,org-babel-lilypond-prologue)))
(setq org-plantuml-jar-path puml-plantuml-jar-path)
(when (file-exists-p "~/.plantuml")
(add-to-list 'org-babel-default-header-args:plantuml
'(:cmdline . "-config ~/.plantuml")))
(defadvice org-edit-src-code (around set-buffer-file-name activate compile)
"Assign a proper filename to the edit-src buffer, so plugins like quickrun
will function properly."
(let ((buffer-name (buffer-name))
(file-name (buffer-file-name)))
ad-do-it
(setq buffer-file-name file-name)
(message "--%s :: %s" buffer-name (buffer-name))))
;; Add plantuml syntax highlighting support
(add-to-list 'org-src-lang-modes '("puml" . puml))
(add-to-list 'org-src-lang-modes '("plantuml" . puml)))
(defun narf@org-latex ()
(setq-default
org-latex-preview-ltxpng-directory (concat narf-temp-dir "ltxpng/")
org-latex-remove-logfiles nil
org-latex-create-formula-image-program 'dvipng
org-startup-with-latex-preview nil
org-highlight-latex-and-related '(latex)
org-format-latex-options (plist-put org-format-latex-options :scale 1.2)
org-latex-image-default-width nil
org-latex-packages-alist
'(;; ("" "gauss" t)
;; ("" "physics" t) TODO Install this
)))
(defun narf@org-looks ()
(setq-default
org-image-actual-width nil
org-startup-with-inline-images nil
org-startup-indented t
org-pretty-entities nil
org-pretty-entities-include-sub-superscripts t
org-use-sub-superscripts '{}
org-fontify-whole-heading-line nil
org-fontify-done-headline t
org-fontify-quote-and-verse-blocks t
org-ellipsis 'hs-face
org-indent-indentation-per-level 2
org-cycle-separator-lines 2
org-hide-emphasis-markers t
org-hide-leading-stars t
org-bullets-bullet-list '("" "" "" "" "" "")
org-entities-user
'(("flat" "\\flat" nil "" "" "266D" "")
("sharp" "\\sharp" nil "" "" "266F" "")))
(add-hook! org-mode
(highlight-regexp org-any-link-re 'org-link))
;; Restore org-block-background face (removed in official org)
;; (defface org-block-background '((t ())) "Face used for the source block background.")
;; (defun narf--adjoin-to-list-or-symbol (element list-or-symbol)
;; (let ((list (if (not (listp list-or-symbol))
;; (list list-or-symbol)
;; list-or-symbol)))
;; (require 'cl-lib)
;; (cl-adjoin element list)))
;; (set-face-attribute 'org-block-background nil :inherit
;; (narf--adjoin-to-list-or-symbol
;; 'fixed-pitch
;; (face-attribute 'org-block-background :inherit)))
;; Prettify symbols, blocks and TODOs
(defface org-headline-todo '((t ())) "Face for todo headlines")
(defface org-headline-done '((t ())) "Face for todo headlines")
(defface org-todo-high '((t ())) "Face for high-priority todo")
(defface org-todo-vhigh '((t ())) "Face for very high-priority todo")
;; (defface org-whitespace '((t ())) "Face for spaces")
(defface org-list-bullet '((t ())) "Face for list bullets")
(defface org-todo-checkbox '((t ())) "Face for list bullets")
(defvar narf-org-font-lock-keywords
'(("^ *\\([-+]\\|[0-9]+[).]\\)[^$\n\r]"
(1 'org-list-bullet))
;; Crossed out finished items
("\\* \\(?:DONE\\|PAID\\) \\([^$\n\r]+\\)"
(1 'org-headline-done))
("^ *\\(?:[-+]\\|[0-9]+[).]\\) \\[X\\] \\([^$\n\r]+\\)"
(1 'org-headline-done))))
(font-lock-add-keywords 'org-mode narf-org-font-lock-keywords))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun narf|org-hook ()
(evil-org-mode +1)
(org-indent-mode +1)
(setq line-spacing '1)
(setq header-line-format mode-line-format
mode-line-format '("%e"))
(visual-line-mode +1)
(visual-fill-column-mode +1)
(when write-mode
(org-bullets-mode +1))
;;; OS-Specific
(cond (IS-MAC (narf-org-init-for-osx))
(IS-LINUX nil)
(IS-WINDOWS nil))
(defun narf|org-update-statistics-cookies ()
(when (file-exists-p buffer-file-name)
(org-update-statistics-cookies t)))
(add-hook 'before-save-hook 'narf|org-update-statistics-cookies nil t)
(add-hook 'evil-insert-state-exit-hook 'narf|org-update-statistics-cookies nil t)
;; If saveplace places the point in a folded position, unfold it on load
(when (outline-invisible-p)
(ignore-errors
(save-excursion
(outline-previous-visible-heading 1)
(org-show-subtree))))
;; Custom Ex Commands
(exmap! "src" 'org-edit-special)
(exmap! "refile" 'org-refile)
(exmap! "archive" 'org-archive-subtree)
(exmap! "agenda" 'org-agenda)
(exmap! "todo" 'org-show-todo-tree)
(exmap! "link" 'org-link)
(exmap! "wc" 'narf/org-word-count)
(exmap! "at[tach]" 'narf:org-attach)
(exmap! "export" 'narf:org-export))
(defun narf|org-init ()
(narf@org-vars)
(narf@org-babel)
(narf@org-latex)
(narf@org-looks)
(narf@org-export)
(add-hook 'org-mode-hook 'narf|org-hook)
;; Don't track attachments
(push (format "/%s.+$" (regexp-quote org-attach-directory)) recentf-exclude)
;; Enable encryption
(require 'epa-file)
(epa-file-enable)
(require 'org-crypt)
(org-crypt-use-before-save-magic)
(setq org-tags-exclude-from-inheritance '("crypt"))
(setq org-crypt-key user-mail-address)
(setq epa-file-encrypt-to user-mail-address)
;; Custom links
(define-org-link! project "Work/Projects" 'f-no-ext)
(define-org-link! invoice "Work/Invoices" 'f-no-ext)
(define-org-link! contact "Work/Contacts" 'f-no-ext)
(define-org-link! dev "Personal/Dev")
(define-org-link! course "Courses"
(lambda (path) (substring path 0 (s-index-of " " path))))
(after! helm
(mapc (lambda (r) (add-to-list 'helm-boring-file-regexp-list r))
(list "\\.attach$" "\\.Rhistory$")))
;; fix some org-mode + yasnippet conflicts:
(defun yas/org-very-safe-expand ()
(let ((yas-fallback-behavior 'return-nil)) (yas-expand)))
(add-hook! org-mode
(make-variable-buffer-local 'yas-trigger-key)
(setq yas/trigger-key [tab])
(add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
(define-key yas-keymap [tab] 'yas-next-field))
;;; Evil integration
(progn
(advice-add 'evil-force-normal-state :before 'org-remove-occur-highlights)
;; Add element delimiter text-objects so we can use evil-surround to
;; manipulate them.
(define-text-object! "$" "\\$" "\\$")
(define-text-object! "*" "\\*" "\\*")
(define-text-object! "/" "/" "/")
(define-text-object! "_" "_" "_")
(define-text-object! "=" "=" "=")
(define-text-object! "~" "~" "~"))
;;; Plugins
(require 'org-download)
(setq-default
org-download-image-dir (expand-file-name ".attach" org-directory)
org-download-heading-lvl nil
org-download-timestamp "_%Y%m%d_%H%M%S")
(when IS-MAC
(setq org-download-screenshot-method "screencapture -i %s"))
;; Write download paths relative to current file
(defun org-download--dir-2 () nil)
(defun narf*org-download--fullname (path)
(f-relative path (f-dirname (buffer-file-name))))
(advice-add 'org-download--fullname :filter-return 'narf*org-download--fullname)
;; Let org-download also handle PDFs
;;; Auto-completion
(after! company
(require 'company-math)
(define-company-backend! org-mode
(math-symbols-latex
math-symbols-unicode
latex-commands
capf
yasnippet
dabbrev-code
keywords)))
(define-key org-mode-map (kbd "RET") nil)
(define-key org-mode-map (kbd "C-j") nil)
(define-key org-mode-map (kbd "C-k") nil)
;; Keybinds
(map! (:map org-mode-map
:i [remap narf/inflate-space-maybe] 'org-self-insert-command
:i "RET" 'org-return-indent)
(:map evil-org-mode-map
:ni "A-l" 'org-metaright
:ni "A-h" 'org-metaleft
:ni "A-k" 'org-metaup
:ni "A-j" 'org-metadown
;; Expand tables (or shiftmeta move)
:ni "A-L" 'narf/org-table-append-field-or-shift-right
:ni "A-H" 'narf/org-table-prepend-field-or-shift-left
:ni "A-K" 'narf/org-table-prepend-row-or-shift-up
:ni "A-J" 'narf/org-table-append-row-or-shift-down
:i "C-L" 'narf/org-table-next-field
:i "C-H" 'narf/org-table-previous-field
:i "C-K" 'narf/org-table-previous-row
:i "C-J" 'narf/org-table-next-row
:i "C-e" 'org-end-of-line
:i "C-a" 'org-beginning-of-line
:nv "j" 'evil-next-visual-line
:nv "k" 'evil-previous-visual-line
:v "<S-tab>" 'narf/yas-insert-snippet
:i "M-a" (λ! (evil-visual-state) (org-mark-element))
:n "M-a" 'org-mark-element
:v "M-a" 'mark-whole-buffer
:ni "<M-return>" (λ! (narf/org-insert-item 'below))
:ni "<S-M-return>" (λ! (narf/org-insert-item 'above))
:i "M-b" (λ! (narf/org-surround "*")) ; bold
:i "M-u" (λ! (narf/org-surround "_")) ; underline
:i "M-i" (λ! (narf/org-surround "/")) ; italics
:i "M-`" (λ! (narf/org-surround "+")) ; strikethrough
:v "M-b" "S*"
:v "M-u" "S_"
:v "M-i" "S/"
:v "M-`" "S+"
(:leader
:n ";" 'helm-org-in-buffer-headings
:n "oa" 'narf/org-attachment-reveal)
(:localleader
:n "/" 'org-sparse-tree
:n "?" 'org-tags-view
:n "n" (λ! (if (buffer-narrowed-p) (widen) (org-narrow-to-subtree)))
:n "e" 'org-edit-special
:n "=" 'org-align-all-tags
:nv "l" 'org-insert-link
:n "L" 'org-store-link
:n "x" 'narf/org-remove-link
;; :n "w" 'writing-mode
:n "v" 'variable-pitch-mode
:n "SPC" 'narf/org-toggle-checkbox
:n "RET" 'org-archive-subtree
:n "a" 'org-agenda
:n "A" 'narf:org-attachment-list
:n "d" 'org-time-stamp
:n "D" 'org-time-stamp-inactive
:n "i" 'narf/org-toggle-inline-images-at-point
:n "t" (λ! (org-todo (if (org-entry-is-todo-p) 'none 'todo)))
:n "T" 'org-todo
:n "s" 'org-schedule
:n "r" 'org-refile
:n "R" (λ! (org-metaleft) (org-archive-to-archive-sibling)) ; archive to parent sibling
:n "op" 'narf/org-open-project-at-pt
:n "oc" 'narf/org-open-contact-at-pt
:n "oi" 'narf/org-open-invoice-at-pt
)
;; TODO Improve folding bindings
:n "za" 'org-cycle
:n "zA" 'org-shifttab
:n "zm" (λ! (outline-hide-sublevels 1))
:n "zr" 'outline-show-all
:n "zo" 'outline-show-subtree
:n "zO" 'outline-show-all
:n "zc" 'outline-hide-subtree
:n "zC" (λ! (outline-hide-sublevels 1))
:n "zd" (lambda (&optional arg) (interactive "p") (outline-hide-sublevels (or arg 3)))
:m "]]" (λ! (call-interactively 'org-forward-heading-same-level) (org-beginning-of-line))
:m "[[" (λ! (call-interactively 'org-backward-heading-same-level) (org-beginning-of-line))
:m "]l" 'org-next-link
:m "[l" 'org-previous-link
:n "RET" 'narf/org-dwim-at-point
:m "gh" 'outline-up-heading
:m "gj" 'org-forward-heading-same-level
:m "gk" 'org-backward-heading-same-level
:m "gl" (λ! (call-interactively 'outline-next-visible-heading) (show-children))
:n "go" 'org-open-at-point
:n "gO" (λ! (let ((org-link-frame-setup (append '((file . find-file-other-window)) org-link-frame-setup))
(org-file-apps '(("\\.org$" . emacs)
(t . "open \"%s\""))))
(call-interactively 'org-open-at-point)))
:n "gQ" 'org-fill-paragraph
:m "$" 'org-end-of-line
:m "^" 'org-beginning-of-line
:n "<" 'org-metaleft
:n ">" 'org-metaright
:v "<" (λ! (org-metaleft) (evil-visual-restore))
:v ">" (λ! (org-metaright) (evil-visual-restore))
:n "-" 'org-cycle-list-bullet
:n [tab] 'org-cycle)
(:map org-src-mode-map
:n "<escape>" (λ! (message "Exited") (org-edit-src-exit)))
(:after org-agenda
(:map org-agenda-mode-map
:e "<escape>" 'org-agenda-Quit
:e "C-j" 'org-agenda-next-item
:e "C-k" 'org-agenda-previous-item
:e "C-n" 'org-agenda-next-item
:e "C-p" 'org-agenda-previous-item)))
(progn ;; Org hacks
(defun org-fontify-meta-lines-and-blocks-1 (limit)
"Fontify #+ lines and blocks."
(let ((case-fold-search t))
(if (re-search-forward
"^\\([ \t]*#\\(\\(\\+[a-zA-Z]+:?\\| \\|$\\)\\(_\\([a-zA-Z]+\\)\\)?\\)[ \t]*\\(\\([^ \t\n]*\\)[ \t]*\\(.*\\)\\)\\)"
limit t)
(let ((beg (match-beginning 0))
(block-start (match-end 0))
(block-end nil)
(lang (match-string 7))
(beg1 (line-beginning-position 2))
(dc1 (downcase (match-string 2)))
(dc3 (downcase (match-string 3)))
end end1 quoting block-type ovl)
(cond
((and (match-end 4) (equal dc3 "+begin"))
;; Truly a block
(setq block-type (downcase (match-string 5))
quoting (member block-type org-protecting-blocks))
(when (re-search-forward
(concat "^[ \t]*#\\+end" (match-string 4) "\\>.*")
nil t) ;; on purpose, we look further than LIMIT
(setq end (min (point-max) (match-end 0))
end1 (min (point-max) (1- (match-beginning 0))))
(setq block-end (match-beginning 0))
(when quoting
(org-remove-flyspell-overlays-in beg1 end1)
(remove-text-properties beg end
'(display t invisible t intangible t)))
(add-text-properties
beg end '(font-lock-fontified t font-lock-multiline t))
(add-text-properties beg beg1 '(face org-meta-line))
(org-remove-flyspell-overlays-in beg beg1)
(add-text-properties ; For end_src
end1 (min (point-max) (1+ end)) '(face org-meta-line))
(org-remove-flyspell-overlays-in end1 end)
(cond
((and lang (not (string= lang "")) org-src-fontify-natively)
(org-src-font-lock-fontify-block lang block-start block-end)
;;;;;;; EDIT
;; remove old background overlays
(mapc (lambda (ov)
(if (eq (overlay-get ov 'face) 'org-block-background)
(delete-overlay ov)))
(overlays-at (/ (+ beg1 block-end) 2)))
;; add a background overlay
(setq ovl (make-overlay beg1 block-end))
(overlay-put ovl 'face 'org-block-background)
(overlay-put ovl 'evaporate t)) ; make it go away when empty
;; (add-text-properties beg1 block-end '(src-block t)))
;;;;;;; /EDIT
(quoting
(add-text-properties beg1 (min (point-max) (1+ end1))
'(face org-block))) ; end of source block
((not org-fontify-quote-and-verse-blocks))
((string= block-type "quote")
(add-text-properties beg1 (min (point-max) (1+ end1)) '(face org-quote)))
((string= block-type "verse")
(add-text-properties beg1 (min (point-max) (1+ end1)) '(face org-verse))))
(add-text-properties beg beg1 '(face org-block-begin-line))
(add-text-properties (min (point-max) (1+ end)) (min (point-max) (1+ end1))
'(face org-block-end-line))
t))
((string-match-p
(format "^\\+%s+:$"
(regexp-opt '("title" "author" "email" "date" "address" "location" "contact"
"project" "country" "city" "created" "issued" "paid" "currency")))
dc1)
;; (member dc1 '("+title:" "+author:" "+email:" "+date:" "+address:" "+location:" "+contact:" "+project:"))
(org-remove-flyspell-overlays-in
(match-beginning 0)
(if (equal "+title:" dc1) (match-end 2) (match-end 0)))
(add-text-properties
beg (match-end 3)
(if (member (intern (substring dc1 1 -1)) org-hidden-keywords)
'(font-lock-fontified t invisible t)
'(font-lock-fontified t face org-document-info-keyword)))
(add-text-properties
(match-beginning 6) (min (point-max) (1+ (match-end 6)))
(if (string-equal dc1 "+title:")
'(font-lock-fontified t face org-document-title)
'(font-lock-fontified t face org-document-info))))
((equal dc1 "+caption:")
(org-remove-flyspell-overlays-in (match-end 2) (match-end 0))
(remove-text-properties (match-beginning 0) (match-end 0)
'(display t invisible t intangible t))
(add-text-properties (match-beginning 1) (match-end 3)
'(font-lock-fontified t face org-meta-line))
(add-text-properties (match-beginning 6) (+ (match-end 6) 1)
'(font-lock-fontified t face org-block))
t)
((member dc3 '(" " ""))
(org-remove-flyspell-overlays-in beg (match-end 0))
(add-text-properties
beg (match-end 0)
'(font-lock-fontified t face font-lock-comment-face)))
(t ;; just any other in-buffer setting, but not indented
(org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
(remove-text-properties (match-beginning 0) (match-end 0)
'(display t invisible t intangible t))
(add-text-properties beg (match-end 0)
'(font-lock-fontified t face org-meta-line))
t))))))
)
)
(provide 'module-org)
;;; module-org.el ends here

View file

@ -1,162 +0,0 @@
;; module-write.el
;; This library offers the following:
;; + Write-mode: a mode that turns Emacs into an app for writing notes, papers, or
;; fiction: it adds eye-candy to org-mode, switches to a light color theme and
;; to a more readable font.
;; + Bibtex integration
;; Write-mode settings
(defconst write-mode nil)
(defconst write-mode-theme 'narf-write)
(defconst write-mode-font (font-spec :family "Hack" :size 12))
(defconst write-mode-dir "~/Dropbox/notes")
(defconst write-mode-biblio-dir "~/Dropbox/docs/biblio")
(defconst write-mode--last-mode-line mode-line-format)
(defconst write-mode--last-line-spacing line-spacing)
(defvar write-mode-org-font-lock-keywords
`(;; ("^\\(\\*\\*?\\)\\( \\)"
;; (1 'font-lock-comment-face t)
;; (2 'variable-pitch))
("^ *\\(\\(?:[-+]\\|[0-9]+[).]\\) \\[ \\]\\)\\( \\)"
(1 (narf/show-as ?☐))
(2 'variable-pitch append))
("^ *\\(\\(?:[-+]\\|[0-9]+[.)]\\) \\[X\\]\\)\\( \\)"
(1 (narf/show-as ?☑))
(2 'variable-pitch append))
;; Hide TODO tags
(,(concat
"\\(\\*\\) "
(regexp-opt '("IDEA" "NEXT" "ACTIVE" "WAITING" "LATER" "CANCELLED" "UNPAID" "UNSENT"))
" ")
(1 (narf/show-as ?☐)))
("\\(\\* \\(?:DONE\\|PAID\\)\\)\\( \\)\\([^$\n\r]+\\)"
(1 (narf/show-as ?☑))
(2 'variable-pitch t)
(3 'org-headline-done append))
("\\(\\* TODO\\)\\( \\)"
(1 (narf/show-as ?☐))
(2 'variable-pitch t))
("[-+*] \\[X\\] \\([^$\n\r]+\\)"
(1 'org-headline-done))
("^ *\\([-+]\\|[0-9]+[).]\\)\\( \\)+[^$\n\r]"
(1 'org-list-bullet)
(2 'variable-pitch append))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun write-mode|org-hook ()
"A hook that runs everytime an org-mode buffer is visited/created while `write-mode' is
active."
(font-lock-add-keywords nil write-mode-org-font-lock-keywords))
(defun write-mode-toggle ()
"Enable write-mode, this is not a [global] minor mode because it mixes some frame-local
functionality with buffer-local ones, which can be buggy in a minor-mode."
(interactive)
(let* ((mode-p write-mode)
(on-off (if mode-p -1 +1)))
;; (disable-theme (if mode-p write-mode-theme narf-theme))
;; (scroll-bar-mode on-off)
;; (narf/load-theme (if mode-p narf-theme write-mode-theme))
(narf/load-font (if mode-p narf-default-font write-mode-font))
(when (featurep 'volatile-highlights)
(volatile-highlights-mode (not on-off)))
(when IS-MAC
(setq mouse-wheel-scroll-amount
(if mode-p '(5 ((shift) . 2)) '(3 ((shift) . 2)))))
(if write-mode
(remove-hook 'org-mode-hook 'write-mode|org-hook)
(add-hook 'org-mode-hook 'write-mode|org-hook))
(mapc (lambda (b)
(with-current-buffer b
(setq line-spacing (if mode-p write-mode--last-line-spacing '2))
(when (eq major-mode 'org-mode)
(if write-mode
(font-lock-remove-keywords nil write-mode-org-font-lock-keywords)
(write-mode|org-hook))
(org-bullets-mode on-off))))
(narf/get-buffers-in-modes '(org-mode markdown-mode)))
(setq write-mode (not write-mode))))
(evil-define-command narf:set-columns (&optional bang columns)
"Adjusts visual-fill-column-width on the fly."
(interactive "<!><a>")
(if (or (= (length columns) 0) bang)
(progn
(setq visual-fill-column-width 80)
(when visual-fill-column-mode
(visual-fill-column-mode -1)))
(setq columns (string-to-number columns))
(when (> columns 30)
(setq visual-fill-column-width columns)))
(if visual-fill-column-mode
(visual-fill-column--adjust-window)
(visual-fill-column-mode 1)))
(when (>= emacs-major-version 25)
;; From <https://github.com/joostkremers/visual-fill-column/pull/6>
;; Splitting windows while visual-fill-column makes Emacs go crazy. This prevents that
;; by simply disabled VFC before splitting.
(after! visual-fill-column
(advice-add 'split-window :around #'visual-fill-column--disable-on-split-window))
(defun visual-fill-column--disable-on-split-window (fn window &rest args)
"Undo the effects of `visual-fill-column-mode' for splitting window."
(if (and (or (not window) (window-live-p window))
(buffer-local-value 'visual-fill-column-mode
(window-buffer (or window (selected-window)))))
(let ((inhibit-redisplay t))
(set-window-fringes (or window (selected-window)) nil)
(set-window-margins (or window (selected-window)) 0 0)
(unwind-protect (apply fn window args)
(save-selected-window
(when window (select-window window 'norecord))
(visual-fill-column--adjust-window))))
(apply fn window args))))
;;; LaTeX
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq bibtex-dialect 'biblatex)
(setq bibtex-align-at-equal-sign t)
(setq bibtex-text-indentation 20)
(add-hook! bibtex-mode
(local-set-key (kbd "C-c \\") 'bibtex-fill-entry)
(setq fill-column 140))
(add-hook! latex-mode 'turn-on-auto-fill)
(add-hook! LaTeX-mode 'turn-on-auto-fill)
(use-package reftex
:config
(add-hook 'latex-mode-hook 'turn-on-reftex)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t
reftex-ref-style-default-list '("Cleveref" "Hyperref" "Fancyref")
reftex-default-bibliography
`(,(expand-file-name "phys.bib" write-mode-biblio-dir))))
;;; Bibtex
;; NOTE: http://bibdesk.sourceforge.net/
(use-package helm-bibtex
:defer t
:config
(setq helm-bibtex-bibliography
`(,(expand-file-name "phys.bib" write-mode-biblio-dir))
helm-bibtex-library-path
`(,(expand-file-name "phys-pdf" write-mode-biblio-dir))
helm-bibtex-notes-path (expand-file-name "notes" write-mode-biblio-dir)
helm-bibtex-notes-extension ".org"
helm-bibtex-pdf-open-function
(lambda (fpath) (async-start-process "open-pdf" "/usr/bin/open" nil fpath))))
(provide 'module-write)
;;; module-write.el ends here

View file

@ -58,15 +58,6 @@
;; Presentation/demo ;; Presentation/demo
(exmap "big" 'big-mode) (exmap "big" 'big-mode)
(exmap "full[scr]" 'narf:toggle-fullscreen) (exmap "full[scr]" 'narf:toggle-fullscreen)
(exmap "wr[iting]" 'write-mode-toggle)
;; Org-mode
(exmap "cols" 'narf:set-columns)
(exmap "org" 'narf/helm-org)
(exmap "cap[ture]" 'helm-org-capture-templates)
(exmap "cont[act]" 'narf:org-crm-contact)
(exmap "proj[ect]" 'narf:org-crm-project)
(exmap "invo[ice]" 'narf:org-crm-invoice)
;; Sessions/tabs ;; Sessions/tabs
(exmap "sl[oad]" 'narf:load-session) (exmap "sl[oad]" 'narf:load-session)