diff --git a/config.org b/config.org index da1b619..20becf0 100644 --- a/config.org +++ b/config.org @@ -1,4 +1,15 @@ -* Systems +* Systems and custom functions + +Firstly, tell Emacs where to look for custom functions (via [[https://www.emacswiki.org/emacs/LoadingLispFiles][EmacsWiki]]). + +#+BEGIN_SRC emacs-lisp + (defun load-directory (dir) + "Add all files in a directory to load-path" + (let ((load-it (lambda (f) + (load-file (concat (file-name-as-directory dir) f))))) + (mapc load-it (directory-files dir nil "\\.el$")))) + (load-directory "~/.emacs.d/custom/") +#+END_SRC Define functions that specify what OS I’m on, also whether I’m at work or not. Then I can implement specific packages according to need/compatibility. @@ -27,7 +38,9 @@ Set name and location based on who I’m being right now. #+BEGIN_SRC emacs-lisp (if (atwork) (load-file "~/Documents/drive/admin/emacs/identity-work.el") - (load-file "~/Documents/drive/admin/emacs/identity-home.el")) + (if workhours + (load-file "~/Documents/drive/admin/emacs/identity-work.el") + (load-file "~/Documents/drive/admin/emacs/identity-home.el"))) #+END_SRC * It's not 1986 @@ -62,17 +75,6 @@ Also suppress certain warnings that would otherwise come up all the time and con * Miscellaneous changes to make to the basic config -Firstly, tell Emacs where to look for custom functions (via [[https://www.emacswiki.org/emacs/LoadingLispFiles][EmacsWiki]]). - -#+BEGIN_SRC emacs-lisp - (defun load-directory (dir) - "Add all files in a directory to load-path" - (let ((load-it (lambda (f) - (load-file (concat (file-name-as-directory dir) f))))) - (mapc load-it (directory-files dir nil "\\.el$")))) - (load-directory "~/.emacs.d/custom/") -#+END_SRC - I don’t want finding files to be case-sensitive, same as in =zsh=: #+BEGIN_SRC emacs-lisp @@ -506,7 +508,7 @@ Add a couple of classes for LaTeX export. '("article-std" "\\documentclass{article} [NO-DEFAULT-PACKAGES] - \\input{$HOME/.emacs.d/header.tex} %$" + \\input{$HOME/.emacs.d/header.tex} %$\n% latexbib" ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))) @@ -536,7 +538,11 @@ Settings for export, mostly for DW post previews but also fic?? And work I guess (progn (setq org-export-with-author nil) (setq org-latex-default-class "article-std")) - (setq org-latex-default-class "memoir")) + (if workhours + (progn + (setq org-export-with-author nil) + (setq org-latex-default-class "article-std")) + (setq org-latex-default-class "memoir"))) (setq org-latex-compiler "xelatex") (setq org-html-validation-link nil) (setq org-html-doctype "html5") @@ -655,18 +661,10 @@ Set the files to be included. (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/acwri.org")) (progn (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/home.org") - (if workday - (if (< (string-to-number (format-time-string "%H")) 19) - (if (> (string-to-number (format-time-string "%H")) 7) - (progn - (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/work.org") - (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/acwri.org")) - (progn - (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/personal.org") - (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/habit.org"))) - (progn - (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/personal.org") - (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/habit.org"))) + (if workhours + (progn + (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/work.org") + (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/acwri.org")) (progn (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/personal.org") (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/habit.org"))))) diff --git a/custom/fic.el b/custom/fic.el index dc37a18..fe24182 100644 --- a/custom/fic.el +++ b/custom/fic.el @@ -61,6 +61,7 @@ (if multichapter (setq chaptertitles (y-or-n-p "Titled chapters?"))) (setq ffx (y-or-n-p "FFX fic?")))) + (setq draftmode (y-or-n-p "Edit LaTeX file manually?")) (org-format) (save-buffer) (goto-char (point-min)) @@ -217,23 +218,25 @@ (replace-match "\\begin{document}\n\\pagestyle{plain}" nil t))))) (goto-char (point-max)) (save-buffer) - (shell-command - (format "xelatex -interaction=batchmode %s" - (shell-quote-argument (buffer-file-name)))) - (shell-command - (format "xelatex -interaction=batchmode %s" - (shell-quote-argument (buffer-file-name)))) + (unless draftmode + (shell-command + (format "xelatex -interaction=batchmode %s" + (shell-quote-argument (buffer-file-name)))) + (shell-command + (format "xelatex -interaction=batchmode %s" + (shell-quote-argument (buffer-file-name))))) (kill-current-buffer)) - (delete-file "FFXYevon.ttf") - (if (file-exists-p (concat (file-name-base) ".aux")) - (delete-file (concat (file-name-base) ".aux"))) - (if (file-exists-p (concat (file-name-base) ".log")) - (delete-file (concat (file-name-base) ".log"))) - (if (file-exists-p (concat (file-name-base) ".out")) - (delete-file (concat (file-name-base) ".out"))) - (if (file-exists-p (concat (file-name-base) ".toc")) - (delete-file (concat (file-name-base) ".toc"))) - (if (file-exists-p "texput.log") - (delete-file "texput.log")) - (delete-file texfile) + (unless draftmode + (delete-file "FFXYevon.ttf") + (if (file-exists-p (concat (file-name-base) ".aux")) + (delete-file (concat (file-name-base) ".aux"))) + (if (file-exists-p (concat (file-name-base) ".log")) + (delete-file (concat (file-name-base) ".log"))) + (if (file-exists-p (concat (file-name-base) ".out")) + (delete-file (concat (file-name-base) ".out"))) + (if (file-exists-p (concat (file-name-base) ".toc")) + (delete-file (concat (file-name-base) ".toc"))) + (if (file-exists-p "texput.log") + (delete-file "texput.log")) + (delete-file texfile)) (message "Done")) diff --git a/custom/org-format.el b/custom/org-format.el index c1a51df..7fb64ee 100644 --- a/custom/org-format.el +++ b/custom/org-format.el @@ -11,15 +11,24 @@ (while (re-search-forward "/ –" nil t) (replace-match " –/")) (goto-char (point-min)) - (while (re-search-forward " \\.\\.\\." nil t) - (replace-match " …")) + (while (re-search-forward "\\.\\.\\." nil t) + (replace-match "…")) + (goto-char (point-min)) + (while (re-search-forward "…" nil t) + (replace-match " … ")) + (goto-char (point-min)) + (while (re-search-forward "  …" nil t) + (replace-match " …")) (goto-char (point-min)) - (while (re-search-forward " …" nil t) + (while (re-search-forward "  +…" nil t) (replace-match " …")) (goto-char (point-min)) (while (re-search-forward "'" nil t) (replace-match "’")) (goto-char (point-min)) + (while (re-search-forward " +" nil t) + (replace-match " ")) + (goto-char (point-min)) (while (re-search-forward " \n" nil t) (replace-match "\n")) (goto-char (point-min)) @@ -55,6 +64,10 @@ (interactive) (org-format) (goto-char (point-min)) + (let ((case-fold-search nil)) + (while (re-search-forward "oe" nil t) + (replace-match "œ"))) + (goto-char (point-min)) (while (re-search-forward " …" nil t) (replace-match "…")) (goto-char (point-min)) diff --git a/custom/workday.el b/custom/workday.el index a352996..571bd95 100644 --- a/custom/workday.el +++ b/custom/workday.el @@ -1,4 +1,9 @@ (load-file "~/Documents/drive/admin/emacs/daysoff.el") + +(defcustom workday nil + "Returns true on working days" + :type 'boolean) + (if (equal (format-time-string "%a") "Sat") (setq workday nil) (if (equal (format-time-string "%a") "Sun") @@ -6,3 +11,12 @@ (if (member (format-time-string "%Y-%m-%d") daysoff) (setq workday nil) (setq workday t)))) + +(defcustom workhours nil + "Returns true during working hours" + :type 'boolean) + +(if workday + (if (< (string-to-number (format-time-string "%H")) 19) + (if (> (string-to-number (format-time-string "%H")) 7) + (setq workhours t)))) diff --git a/snippets/latex-mode/latexbib b/snippets/latex-mode/latexbib index e35e5c1..2fb69d0 100644 --- a/snippets/latex-mode/latexbib +++ b/snippets/latex-mode/latexbib @@ -1,6 +1,7 @@ # name: latex-bibsetup # key: latexbib # -- +% \usepackage[style=authoryear-ibid,alldates=long,giveninits=true,dashed=false,labeldate=year,mergedate=maximum,maxbibnames=10,ibidpage=true,uniquename=false]{biblatex} \renewbibmacro*{volume+number+eid}{ % puts issue number in brackets