diff --git a/config.org b/config.org index f0e8e5f..b9421fd 100644 --- a/config.org +++ b/config.org @@ -1,35 +1,21 @@ * 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/") - (load-directory "~/Documents/drive/admin/emacs/custom/") + (if (string-equal system-type "android") + (setq fileroot "/storage/emulated/0/Documents/") + (setq fileroot "~/Documents/drive/")) #+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. - -#+BEGIN_SRC emacs-lisp - (defun islin () - "Return true if on linux" - (string-equal system-type "gnu/linux")) - - (defun iswin () - "Return true if on windows" - (string-equal system-type "windows-nt")) - - (defun ismac () ;; unlikely now, but might as well keep this - "Return true if on macos" - (string-equal system-type "darwin")) + Firstly, tell Emacs where to look for custom functions (via [[https://www.emacswiki.org/emacs/LoadingLispFiles][EmacsWiki]]). - (defun atwork () - "Return true if at work" - (string-equal user-login-name "3055822")) + #+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/") + (load-directory (concat (file-name-as-directory fileroot) "admin/emacs/custom/")) #+END_SRC * =$whoami=, a big neckbeard, that’s who @@ -37,11 +23,11 @@ Define functions that specify what OS I’m on, also whether I’m at work or no 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") + (if (string-equal user-login-name "3055822") + (load-file (concat (file-name-as-directory fileroot) "admin/emacs/identity-work.el")) (if workhours - (load-file "~/Documents/drive/admin/emacs/identity-work.el") - (load-file "~/Documents/drive/admin/emacs/identity-home.el"))) + (load-file (concat (file-name-as-directory fileroot) "admin/emacs/identity-work.el")) + (load-file (concat (file-name-as-directory fileroot) "admin/emacs/identity-home.el")))) #+END_SRC * Sonic arts @@ -83,9 +69,10 @@ Make the +window+ /frame/ look nice and clean. Scroll bars behave pointlessly on Make everything just a little tiny bit transparent unless I’m using the boring Windows desktop. #+BEGIN_SRC emacs-lisp - (unless (atwork) - (set-frame-parameter (selected-frame) 'alpha 95) - (add-to-list 'default-frame-alist '(alpha . 95))) + (unless (string-equal system-type "android") + (unless (string-equal user-login-name "3055822") + (set-frame-parameter (selected-frame) 'alpha 95) + (add-to-list 'default-frame-alist '(alpha . 95)))) #+END_SRC Stop creating all those =~= files everywhere. Put them somewhere that I can ignore them. @@ -158,15 +145,15 @@ Make new directories automatically (from [[https://emacsredux.com/blog/2022/06/1 On Linux, I have to tell Emacs to use Chrome for web links. #+BEGIN_SRC emacs-lisp - (when (islin) - (setq browse-url-browser-function 'browse-url-generic - browse-url-generic-program "google-chrome")) + (when (string-equal system-type "gnu/linux") + (setq browse-url-browser-function 'browse-url-generic + browse-url-generic-program "google-chrome")) #+END_SRC Honestly I don’t know if I’ll ever use macOS again, but in case I do, I need the meta key to work. #+BEGIN_SRC emacs-lisp - (when (ismac) + (when (string-equal system-type "darwin") (setq ns-alternate-modifier 'meta) (setq ns-right-alternate-modifier 'none)) #+END_SRC @@ -174,29 +161,33 @@ Honestly I don’t know if I’ll ever use macOS again, but in case I do, I need Windows likes to set the default directory to the folder where the Emacs binary is stored, which it probably thinks is helpful, but is in fact Very Stupid. #+BEGIN_SRC emacs-lisp - (when (iswin) + (when (string-equal system-type "windows-nt") (setq default-directory "~/")) #+END_SRC -* =use-package= - -Set up package handling, including =use-package=. Some of the =org= tools I use are from Non-GNU ELPA, I think. Most of this is the standard =use-package= setup stuff. +Android has enormous issues with keybindings, so requiring =yes-or-no-p= where possible helps a bit. #+BEGIN_SRC emacs-lisp - (package-initialize) - - (add-to-list 'package-archives - '("melpa" . "https://melpa.org/packages/") t) - (add-to-list 'package-archives '("nongnu" . "https://elpa.nongnu.org/nongnu/")) + (when (string-equal system-type "android") + (defalias 'y-or-n-p 'yes-or-no-p)) +#+END_SRC - (setq package-check-signature nil) +* =use-package= - (unless (package-installed-p 'use-package) - (package-refresh-contents) - (package-install 'use-package)) +Set up package handling, including =use-package=. Some of the =org= tools I use are from Non-GNU ELPA, I think. Most of this is the standard =use-package= setup stuff. - (require 'use-package-ensure) - (setq use-package-always-ensure t) +#+BEGIN_SRC emacs-lisp + (unless (string-equal system-type "android") + (package-initialize) + (add-to-list 'package-archives + '("melpa" . "https://melpa.org/packages/") t) + (add-to-list 'package-archives '("nongnu" . "https://elpa.nongnu.org/nongnu/")) + (setq package-check-signature nil) + (unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package)) + (require 'use-package-ensure) + (setq use-package-always-ensure t)) #+END_SRC * Packages, modes, etc. @@ -205,10 +196,11 @@ Set up package handling, including =use-package=. Some of the =org= tools I use I use BibLaTeX for better compatibility with accented characters and generally being more sensible. #+BEGIN_SRC - (use-package bibtex +(unless (string-equal system-type "android") +(use-package bibtex :mode ("\\.bib" . bibtex-mode) :config - (setq bibtex-dialect 'biblatex)) + (setq bibtex-dialect 'biblatex))) #+END_SRC ** =calibredb= @@ -216,7 +208,7 @@ I use BibLaTeX for better compatibility with accented characters and generally b This may work only on Linux (it uses SQL???), but my ebooks are only on Linux so that’s ok. #+BEGIN_SRC emacs-lisp - (when (islin) + (when (string-equal system-type "gnu/linux") (use-package calibredb :defer t :config @@ -234,14 +226,15 @@ This may work only on Linux (it uses SQL???), but my ebooks are only on Linux so Let me search my journal files, not synced to my work computer. Set regexp search by default. #+BEGIN_SRC emacs-lisp - (unless (atwork) - (use-package deft - :config - (setq deft-extensions '("org")) - (setq deft-directory "~/Documents/drive/org/journal") - (setq deft-current-sort-method 'title) - (setq deft-incremental-search nil) - (setq deft-recursive t))) + (unless (string-equal system-type "android") + (unless (string-equal user-login-name "3055822") + (use-package deft + :config + (setq deft-extensions '("org")) + (setq deft-directory "~/Documents/drive/org/journal") + (setq deft-current-sort-method 'title) + (setq deft-incremental-search nil) + (setq deft-recursive t)))) #+END_SRC ** =dimmer= @@ -249,12 +242,13 @@ Let me search my journal files, not synced to my work computer. Set regexp searc Dims inactive buffers. Adjustments for =modus-themes= as suggested. #+BEGIN_SRC emacs-lisp - (use-package dimmer - :config - (setq dimmer-fraction 0.4) - (setq dimmer-adjustment-mode :foreground) - (setq dimmer-use-colorspace :rgb) - (dimmer-mode 1)) + (unless (string-equal system-type "android") + (use-package dimmer + :config + (setq dimmer-fraction 0.4) + (setq dimmer-adjustment-mode :foreground) + (setq dimmer-use-colorspace :rgb) + (dimmer-mode 1))) #+END_SRC ** =doom-modeline= @@ -262,15 +256,16 @@ Dims inactive buffers. Adjustments for =modus-themes= as suggested. Much nicer-looking modeline, and still my favourite over newer, trendier options. Last time I tried installing this from MELPA it made Emacs crash; I don’t know if this is fixed yet. #+BEGIN_SRC emacs-lisp - (use-package doom-modeline - :init - (doom-modeline-mode 1) - :config - (setq doom-modeline-buffer-file-name-style 'buffer-name) - (setq doom-modeline-minor-modes t) - (setq doom-modeline-enable-word-count t) - (setq doom-modeline-continuous-word-count-modes '(markdown-mode gfm-mode)) - (setq doom-modeline-buffer-encoding nil)) + (unless (string-equal system-type "android") + (use-package doom-modeline + :init + (doom-modeline-mode 1) + :config + (setq doom-modeline-buffer-file-name-style 'buffer-name) + (setq doom-modeline-minor-modes t) + (setq doom-modeline-enable-word-count t) + (setq doom-modeline-continuous-word-count-modes '(markdown-mode gfm-mode)) + (setq doom-modeline-buffer-encoding nil))) #+END_SRC ** =elfeed= @@ -278,73 +273,72 @@ Much nicer-looking modeline, and still my favourite over newer, trendier options Obviously I use an =org= file to manage my feeds. #+BEGIN_SRC emacs-lisp - (use-package elfeed-org - :config - (elfeed-org) - (setq rmh-elfeed-org-files (list "~/Documents/drive/org/feeds.org"))) + (unless (string-equal system-type "android") + (use-package elfeed-org + :config + (elfeed-org) + (setq rmh-elfeed-org-files (list "~/Documents/drive/org/feeds.org")))) #+END_SRC Standard =elfeed= settings: #+BEGIN_SRC emacs-lisp - (defun elfeed-load-db-and-open () - "Load and open the elfeed DB" - (interactive) - (elfeed-db-load) - (elfeed) - (elfeed-search-update--force) - (elfeed-update)) - - (global-set-key (kbd "C-x w") 'elfeed-load-db-and-open) - - (defalias 'elfeed-toggle-star - (elfeed-expose #'elfeed-search-toggle-all 'star)) - - (eval-after-load 'elfeed-search - '(define-key elfeed-search-mode-map (kbd "m") 'elfeed-toggle-star)) - - (defun elfeed-save-db-and-bury () - "Save and close the elfeed DB" - (interactive) - (elfeed-db-save) - (quit-window)) - - (use-package elfeed - :bind - (:map elfeed-search-mode-map - ("q" . elfeed-save-db-and-bury)) - :custom - (elfeed-sort-order 'ascending) - (elfeed-db-directory "~/Documents/drive/org/elfeed")) + (unless (string-equal system-type "android") + (defun elfeed-load-db-and-open () + "Load and open the elfeed DB" + (interactive) + (elfeed-db-load) + (elfeed) + (elfeed-search-update--force) + (elfeed-update)) + (global-set-key (kbd "C-x w") 'elfeed-load-db-and-open) + (defalias 'elfeed-toggle-star + (elfeed-expose #'elfeed-search-toggle-all 'star)) + (eval-after-load 'elfeed-search + '(define-key elfeed-search-mode-map (kbd "m") 'elfeed-toggle-star)) + (defun elfeed-save-db-and-bury () + "Save and close the elfeed DB" + (interactive) + (elfeed-db-save) + (quit-window)) + (use-package elfeed + :bind + (:map elfeed-search-mode-map + ("q" . elfeed-save-db-and-bury)) + :custom + (elfeed-sort-order 'ascending) + (elfeed-db-directory "~/Documents/drive/org/elfeed"))) #+END_SRC I am a huge supporter of big-endian date formats. #+BEGIN_SRC emacs-lisp - (defun elfeed-search-format-date (date) - "Set elfeed to display big-endian dates" - (format-time-string "%Y-%m-%d %H:%M" (seconds-to-time date))) + (unless (string-equal system-type "android") + (defun elfeed-search-format-date (date) + "Set elfeed to display big-endian dates" + (format-time-string "%Y-%m-%d %H:%M" (seconds-to-time date)))) #+END_SRC This apparently deletes really old entries from the database. #+BEGIN_SRC emacs-lisp - (add-hook 'elfeed-new-entry-hook - (elfeed-make-tagger :before "6 months ago" - :remove 'unread)) + (unless (string-equal system-type "android") + (add-hook 'elfeed-new-entry-hook + (elfeed-make-tagger :before "6 months ago" + :remove 'unread))) #+END_SRC Save elfeed state properly when exiting Emacs. #+BEGIN_SRC emacs-lisp - (defun save-if-elfeed () - "Save the elfeed DB if elfeed is running" - (if (get-buffer "*elfeed-search*") - (progn - (elfeed-db-save) - (message "Elfeed DB saved")))) - - (add-hook 'kill-emacs-hook 'save-if-elfeed) + (unless (string-equal system-type "android") + (defun save-if-elfeed () + "Save the elfeed DB if elfeed is running" + (if (get-buffer "*elfeed-search*") + (progn + (elfeed-db-save) + (message "Elfeed DB saved")))) + (add-hook 'kill-emacs-hook 'save-if-elfeed)) #+END_SRC ** =git-gutter= @@ -352,22 +346,24 @@ Save elfeed state properly when exiting Emacs. Shows, or at least purports to show, =git diff= in the left margin if the file is being tracked by =git=. #+BEGIN_SRC emacs-lisp - (use-package git-gutter - :config - (global-git-gutter-mode 1) - (set-face-foreground 'git-gutter:added "forest green") - (set-face-foreground 'git-gutter:modified "goldenrod") - (set-face-foreground 'git-gutter:deleted "brown") - (setq git-gutter:added-sign "+" - git-gutter:modified-sign "×" - git-gutter:deleted-sign "-")) + (unless (string-equal system-type "android") + (use-package git-gutter + :config + (global-git-gutter-mode 1) + (set-face-foreground 'git-gutter:added "forest green") + (set-face-foreground 'git-gutter:modified "goldenrod") + (set-face-foreground 'git-gutter:deleted "brown") + (setq git-gutter:added-sign "+" + git-gutter:modified-sign "×" + git-gutter:deleted-sign "-"))) #+END_SRC ** =lastfm= #+BEGIN_SRC emacs-lisp - (unless (atwork) - (use-package lastfm)) + (unless (string-equal system-type "android") + (unless (string-equal user-login-name "3055822") + (use-package lastfm))) #+END_SRC ** =markdown-mode= @@ -375,18 +371,19 @@ Shows, or at least purports to show, =git diff= in the left margin if the file i I kind of hate markdown but I still have to use it sometimes. #+BEGIN_SRC emacs-lisp - (use-package markdown-mode - :mode (("README\\.md\\'" . gfm-mode) - ("\\.md\\'" . markdown-mode) - ("\\.markdown\\'" . markdown-mode)) - :hook - (markdown-mode . auto-fill-mode) - :config - (setq markdown-asymmetric-header t) - :custom - (markdown-header-scaling t) - :custom-face - (markdown-header-face ((t (:inherit (default font-lock-function-name-face) :weight bold))))) + (unless (string-equal system-type "android") + (use-package markdown-mode + :mode (("README\\.md\\'" . gfm-mode) + ("\\.md\\'" . markdown-mode) + ("\\.markdown\\'" . markdown-mode)) + :hook + (markdown-mode . auto-fill-mode) + :config + (setq markdown-asymmetric-header t) + :custom + (markdown-header-scaling t) + :custom-face + (markdown-header-face ((t (:inherit (default font-lock-function-name-face) :weight bold)))))) #+END_SRC ** =minions= @@ -394,9 +391,10 @@ I kind of hate markdown but I still have to use it sometimes. Lists minor modes in a menu. #+BEGIN_SRC emacs-lisp - (use-package minions - :config - (minions-mode)) + (unless (string-equal system-type "android") + (use-package minions + :config + (minions-mode))) #+END_SRC ** =mu4e= @@ -404,7 +402,7 @@ Lists minor modes in a menu. I really only use this for DW posts, but I’m constantly surprised by how well it works. This package is the reason I can’t upgrade to =emacs28=, because it doesn’t currently seem to work; also, it uses =cl=, which is deprecated, hence suppressing warnings about it above. #+BEGIN_SRC emacs-lisp - (when (islin) + (when (string-equal system-type "gnu/linux") (add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e") (load-file "~/.emacs.d/mail.el") (require 'mu4e) @@ -416,11 +414,12 @@ I really only use this for DW posts, but I’m constantly surprised by how well Show a nice filetree with icons. I use this much less often than I should. #+BEGIN_SRC emacs-lisp - (use-package neotree - :init - (global-set-key [f8] 'neotree-toggle) - :config - (setq neo-theme (if (display-graphic-p) 'icons 'arrow))) + (unless (string-equal system-type "android") + (use-package neotree + :init + (global-set-key [f8] 'neotree-toggle) + :config + (setq neo-theme (if (display-graphic-p) 'icons 'arrow)))) #+END_SRC ** =nov= @@ -428,7 +427,7 @@ Show a nice filetree with icons. I use this much less often than I should. For reading ebooks. Only on Linux because I (supposedly) use it with my calibre library. #+BEGIN_SRC emacs-lisp - (when (islin) + (when (string-equal system-type "gnu/linux") (use-package nov :init (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))) @@ -451,13 +450,14 @@ I want to indent under headings, I don’t want pointless line breaks when text (setq org-special-ctrl-a/e t) #+END_SRC -Display images in =org= buffers. I’ve increased the width to 500px because 300 was quite small. +Display images in =org= buffers. I’ve increased the width to 500px because 300 was quite small. I’m assuming this doesn’t work on mobile, but why? #+BEGIN_SRC emacs-lisp - (setq org-display-inline-images t) - (setq org-redisplay-inline-images t) - (setq org-startup-with-inline-images "inlineimages") - (setq org-image-actual-width '(500)) + (unless (string-equal system-type "android") + (setq org-display-inline-images t) + (setq org-redisplay-inline-images t) + (setq org-startup-with-inline-images "inlineimages") + (setq org-image-actual-width '(500))) #+END_SRC Load the common agenda settings, i.e. those that I use in conky as well. @@ -484,32 +484,34 @@ Track when I complete todos. This can set certain headlines not to be exported. I haven’t used it yet but it sounds useful. #+BEGIN_SRC emacs-lisp - (use-package org-contrib) - (require 'ox-extra) - (ox-extras-activate '(ignore-headlines)) + (unless (string-equal system-type "android") + (use-package org-contrib) + (require 'ox-extra) + (ox-extras-activate '(ignore-headlines))) #+END_SRC Add a couple of classes for LaTeX export. #+BEGIN_SRC emacs-lisp - (add-to-list 'org-latex-classes - '("article-std" - "\\documentclass{article} - [NO-DEFAULT-PACKAGES] - \\input{$HOME/.emacs.d/header.tex} %$\n% latexbib" - ("\\section{%s}" . "\\section*{%s}") - ("\\subsection{%s}" . "\\subsection*{%s}") - ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))) - (add-to-list 'org-latex-classes - '("memoir" - "\\documentclass[9pt,b6paper]{memoir} - [NO-DEFAULT-PACKAGES] - \\usepackage[namechapters]{optional} - \\input{$HOME/.emacs.d/fic-export-files/header.tex} %$" - ("\\chapter{%s}" . "\\chapter*{%s}") - ("\\section{%s}" . "\\section*{%s}") - ("\\subsection{%s}" . "\\subsection*{%s}") - ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))) + (unless (string-equal system-type "android") + (add-to-list 'org-latex-classes + '("article-std" + "\\documentclass{article} + [NO-DEFAULT-PACKAGES] + \\input{$HOME/.emacs.d/header.tex} %$\n% latexbib" + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))) + (add-to-list 'org-latex-classes + '("memoir" + "\\documentclass[9pt,b6paper]{memoir} + [NO-DEFAULT-PACKAGES] + \\usepackage[namechapters]{optional} + \\input{$HOME/.emacs.d/fic-export-files/header.tex} %$" + ("\\chapter{%s}" . "\\chapter*{%s}") + ("\\section{%s}" . "\\section*{%s}") + ("\\subsection{%s}" . "\\subsection*{%s}") + ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))) #+END_SRC Settings for export, mostly for DW post previews but also fic?? And work I guess, I do that sometimes. @@ -522,16 +524,17 @@ Settings for export, mostly for DW post previews but also fic?? And work I guess (setq org-export-with-creator nil) (setq org-export-with-toc nil) (setq org-export-time-stamp-file nil) - (if (atwork) - (progn - (setq org-export-with-author nil) - (setq org-latex-default-class "article-std")) - (if workhours + (unless (string-equal system-type "android") + (if (string-equal user-login-name "3055822") (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-export-with-author nil) + (setq org-latex-default-class "article-std")) + (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") #+END_SRC @@ -543,14 +546,18 @@ Export non-breaking spaces properly; from, believe it or not, [[https://orgmode. "Keep non-breaking spaces in HTML org export" (when (org-export-derived-backend-p backend 'html) (replace-regexp-in-string " " " " text))) - (add-to-list 'org-export-filter-plain-text-functions - 'my-html-filter-nobreaks) - (defun my-latex-filter-nobreaks (text backend info) - "Keep non-breaking spaces in LaTeX org export" - (when (org-export-derived-backend-p backend 'latex) - (replace-regexp-in-string " " "~" text))) - (add-to-list 'org-export-filter-plain-text-functions - 'my-latex-filter-nobreaks) + (if (string-equal system-type "android") + (setq org-export-filter-plain-text-functions + 'my-html-filter-nobreaks) + (add-to-list 'org-export-filter-plain-text-functions + 'my-html-filter-nobreaks)) + (unless (string-equal system-type "android") + (defun my-latex-filter-nobreaks (text backend info) + "Keep non-breaking spaces in LaTeX org export" + (when (org-export-derived-backend-p backend 'latex) + (replace-regexp-in-string " " "~" text))) + (add-to-list 'org-export-filter-plain-text-functions + 'my-latex-filter-nobreaks)) #+END_SRC *** Packages @@ -560,7 +567,8 @@ Export non-breaking spaces properly; from, believe it or not, [[https://orgmode. Let properties be inherited by subheadings. I use this a lot for =:LOCATION:= on recurring events. #+BEGIN_SRC emacs-lisp - (use-package org-agenda-property) + (unless (string-equal system-type "android") + (use-package org-agenda-property)) #+END_SRC **** =org-journal= @@ -568,20 +576,21 @@ Let properties be inherited by subheadings. I use this a lot for =:LOCATION:= on Automate a tiny part of something I was previously doing manually. #+BEGIN_SRC emacs-lisp - (unless (atwork) - (defun org-journal-file-header-func (time) - "Set the header for org-journal files" - (concat "<" (format-time-string "%Y-%m-%d %a") ">\n\n")) - (use-package org-journal - :bind - ("C-c j" . org-journal-new-entry) - :config - (setq org-journal-dir "~/Documents/drive/org/journal") - (setq org-journal-file-format "%Y/%m/%Y-%m-%d.org") - (setq org-journal-find-file 'find-file) - (setq org-journal-date-format "journal") - (setq org-journal-time-format "%H:%M\n") - (setq org-journal-file-header 'org-journal-file-header-func))) + (unless (string-equal system-type "android") + (unless (string-equal user-login-name "3055822") + (defun org-journal-file-header-func (time) + "Set the header for org-journal files" + (concat "<" (format-time-string "%Y-%m-%d %a") ">\n\n")) + (use-package org-journal + :bind + ("C-c j" . org-journal-new-entry) + :config + (setq org-journal-dir "~/Documents/drive/org/journal") + (setq org-journal-file-format "%Y/%m/%Y-%m-%d.org") + (setq org-journal-find-file 'find-file) + (setq org-journal-date-format "journal") + (setq org-journal-time-format "%H:%M\n") + (setq org-journal-file-header 'org-journal-file-header-func)))) #+END_SRC **** =org-modern= @@ -589,11 +598,12 @@ Automate a tiny part of something I was previously doing manually. Use =org-modern=. [[https://github.com/minad/org-modern/issues/5#issuecomment-1318003940][Fix for issue with table widths]]. #+BEGIN_SRC emacs-lisp - (use-package org-modern - :hook - (org-mode . org-modern-mode)) - (set-face-attribute 'org-table nil :inherit 'fixed-pitch) - (custom-set-variables '(org-modern-table nil)) + (unless (string-equal system-type "android") + (use-package org-modern + :hook + (org-mode . org-modern-mode)) + (set-face-attribute 'org-table nil :inherit 'fixed-pitch) + (custom-set-variables '(org-modern-table nil))) #+END_SRC **** =org-noter= @@ -601,10 +611,11 @@ Use =org-modern=. [[https://github.com/minad/org-modern/issues/5#issuecomment-13 RIP =interleave=, but this does ok as a replacement. #+BEGIN_SRC emacs-lisp - (use-package org-noter - :config - (setq org-noter-property-doc-file "INTERLEAVE_PDF" - org-noter-property-note-location "INTERLEAVE_PAGE_NOTE")) + (unless (string-equal system-type "android") + (use-package org-noter + :config + (setq org-noter-property-doc-file "INTERLEAVE_PDF" + org-noter-property-note-location "INTERLEAVE_PAGE_NOTE"))) #+END_SRC **** =org-sidebar= @@ -612,9 +623,10 @@ RIP =interleave=, but this does ok as a replacement. Display the file outline in a sidebar. #+BEGIN_SRC emacs-lisp - (use-package org-sidebar - :bind - ("C-c C-x s" . org-sidebar-tree)) + (unless (string-equal system-type "android") + (use-package org-sidebar + :bind + ("C-c C-x s" . org-sidebar-tree))) #+END_SRC **** =org-wc= @@ -622,9 +634,10 @@ Display the file outline in a sidebar. Display word counts next to org headings. #+BEGIN_SRC emacs-lisp - (use-package org-wc - :bind - ("C-c C-x w" . org-wc-display)) + (unless (string-equal system-type "android") + (use-package org-wc + :bind + ("C-c C-x w" . org-wc-display))) #+END_SRC *** Agenda settings @@ -641,21 +654,26 @@ Set the keybinding, set the week to start on Monday because I’m not the Univer Set the files to be included. #+BEGIN_SRC emacs-lisp - (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/music.org") - (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/admin.org") - (if (atwork) - (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/home.org") + (if (string-equal system-type "android") (if workhours + (setq org-agenda-files '("/storage/emulated/0/Documents/org/calendar/admin.org" "/storage/emulated/0/Documents/org/calendar/music.org" "/storage/emulated/0/Documents/org/calendar/work.org")) + (setq org-agenda-files '("/storage/emulated/0/Documents/org/calendar/admin.org" "/storage/emulated/0/Documents/org/calendar/music.org" "/storage/emulated/0/Documents/org/calendar/personal.org"))) + (progn + (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/music.org") + (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/admin.org") + (if (string-equal user-login-name "3055822") (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"))))) + (add-to-list 'org-agenda-files "~/Documents/drive/org/calendar/home.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"))))))) #+END_SRC Set how the agenda looks. @@ -682,26 +700,26 @@ Add period information to the agenda header (this has a very weird output, compl Use a horizontal line to divide each day from the next. #+BEGIN_SRC emacs-lisp - (setq org-agenda-format-date (lambda (date) (concat "\n" - (make-string (window-width) 9472) - "\n" - (org-agenda-format-date-aligned date)))) + (unless (string-equal system-type "android") + (setq org-agenda-format-date (lambda (date) (concat "\n" + (make-string (window-width) 9472) + "\n" + (org-agenda-format-date-aligned date))))) #+END_SRC Set up habit display. #+BEGIN_SRC emacs-lisp - (add-to-list 'org-modules 'org-habit t) - (setq org-habit-show-all-today t) + (unless (string-equal system-type "android") + (add-to-list 'org-modules 'org-habit t) + (setq org-habit-show-all-today t)) #+END_SRC ** =paren= Highlights matching bracket. #+BEGIN_SRC emacs-lisp - (use-package paren - :config - (show-paren-mode +1)) + (show-paren-mode +1) #+END_SRC ** =pdf-tools= and =doc-view= @@ -709,16 +727,17 @@ Highlights matching bracket. Use the superior package for viewing PDFs on the superior operating system, and use a less reliable one otherwise. Ghostscript has to be installed on Windows, but it’s indispensable anyway. #+BEGIN_SRC emacs-lisp - (if (iswin) - (use-package doc-view + (unless (string-equal system-type "android") + (if (string-equal system-type "windows-nt") + (use-package doc-view + :config + (setq doc-view-ghostscript-program "gswin32c")) + (use-package pdf-tools :config - (setq doc-view-ghostscript-program "gswin32c")) - (use-package pdf-tools - :config - (pdf-tools-install) - (define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward) - (add-hook 'pdf-view-mode-hook (lambda () (cua-mode 0))) - (setq pdf-view-resize-factor 1.1))) + (pdf-tools-install) + (define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward) + (add-hook 'pdf-view-mode-hook (lambda () (cua-mode 0))) + (setq pdf-view-resize-factor 1.1)))) #+END_SRC ** =recentf= @@ -726,18 +745,16 @@ Use the superior package for viewing PDFs on the superior operating system, and Gives me a dialog with recently opened files. Package management and =elfeed= stuff have to be manually excluded for obvious reasons. Surely I don’t have to call =add-to-list= separately every time, but I haven’t found a more sensible way of doing it. #+BEGIN_SRC emacs-lisp - (use-package recentf - :config - (recentf-mode 1) - (setq recentf-max-menu-items 20) - (setq recentf-max-saved-items 20) - (global-set-key (kbd "C-x C-r") 'recentf-open-files) - (add-to-list 'recentf-exclude - (expand-file-name "~/.emacs.d/elpa/*")) - (add-to-list 'recentf-exclude - (expand-file-name "~/.emacs.d/bookmarks")) - (add-to-list 'recentf-exclude - (expand-file-name "~/Documents/drive/org/elfeed/*"))) + (recentf-mode 1) + (setq recentf-max-menu-items 20) + (setq recentf-max-saved-items 20) + (global-set-key (kbd "C-x C-r") 'recentf-open-files) + (add-to-list 'recentf-exclude + (expand-file-name "~/.emacs.d/elpa/*")) + (add-to-list 'recentf-exclude + (expand-file-name "~/.emacs.d/bookmarks")) + (add-to-list 'recentf-exclude + (expand-file-name "~/Documents/drive/org/elfeed/*")) #+END_SRC ** =tex= @@ -745,21 +762,22 @@ Gives me a dialog with recently opened files. Package management and =elfeed= st As previously described, “the big boy”. I know little about most of these settings, but I think they’re the default ones. #+BEGIN_SRC emacs-lisp - (use-package tex - :ensure auctex - :mode ("\\.tex\\'" . latex-mode) - :init - (add-hook 'LaTeX-mode-hook 'turn-on-auto-fill) - (add-hook 'TeX-after-compilation-finished-functions - #'TeX-revert-document-buffer) - :config - (setq TeX-auto-save t) - (setq TeX-parse-self t) - (setq-default TeX-master nil) - (setq-default TeX-engine 'xetex) - (setq-default TeX-PDF-mode t) - (setq TeX-view-program-selection '((output-pdf "PDF Tools")) - TeX-source-correlate-start-server t)) + (unless (string-equal system-type "android") + (use-package tex + :ensure auctex + :mode ("\\.tex\\'" . latex-mode) + :init + (add-hook 'LaTeX-mode-hook 'turn-on-auto-fill) + (add-hook 'TeX-after-compilation-finished-functions + #'TeX-revert-document-buffer) + :config + (setq TeX-auto-save t) + (setq TeX-parse-self t) + (setq-default TeX-master nil) + (setq-default TeX-engine 'xetex) + (setq-default TeX-PDF-mode t) + (setq TeX-view-program-selection '((output-pdf "PDF Tools")) + TeX-source-correlate-start-server t))) #+END_SRC ** =typo= @@ -767,16 +785,17 @@ As previously described, “the big boy”. I know little about most of these se Automatically use smart quotes. (Can’t be set to =text-mode-hook=, unfortunately, as this messes things up in LaTeX; but the only other text-modes I use are =org= and Markdown, I think.) Also, best to /unset/ this mode in source blocks in =org=, [[https://emacs.stackexchange.com/questions/55944/disable-minor-mode-inside-source-blocks][hook taken from here]]. #+BEGIN_SRC emacs-lisp - (use-package typo - :custom - (typo-global-mode 1) - :hook - (org-mode . typo-mode) - (markdown-mode . typo-mode)) - (defun unsmart-hook () - "Turn off smart quotes for source blocks within org mode" - (add-hook 'typo-disable-electricity-functions 'org-in-src-block-p nil :local)) - (add-hook 'org-mode-hook 'unsmart-hook) + (unless (string-equal system-type "android") + (use-package typo + :custom + (typo-global-mode 1) + :hook + (org-mode . typo-mode) + (markdown-mode . typo-mode)) + (defun unsmart-hook () + "Turn off smart quotes for source blocks within org mode" + (add-hook 'typo-disable-electricity-functions 'org-in-src-block-p nil :local)) + (add-hook 'org-mode-hook 'unsmart-hook)) #+END_SRC ** =web-mode= @@ -784,16 +803,17 @@ Automatically use smart quotes. (Can’t be set to =text-mode-hook=, unfortunate This is good for auto indentation, folding, killing elements, apparently XPath?? but I’ve failed to make faces work like they do in normal =html-mode=. #+BEGIN_SRC emacs-lisp - (use-package web-mode - :mode (("\\.html?\\'" . web-mode) - ("\\.css" . web-mode)) - :config - (setq web-mode-markup-indent-offset 2) - (setq web-mode-css-indent-offset 2) - (setq web-mode-enable-html-entities-fontification t) - (setq web-mode-enable-current-element-highlight t) - :bind - ("C-c /" . web-mode-element-close)) + (unless (string-equal system-type "android") + (use-package web-mode + :mode (("\\.html?\\'" . web-mode) + ("\\.css" . web-mode)) + :config + (setq web-mode-markup-indent-offset 2) + (setq web-mode-css-indent-offset 2) + (setq web-mode-enable-html-entities-fontification t) + (setq web-mode-enable-current-element-highlight t) + :bind + ("C-c /" . web-mode-element-close))) #+END_SRC ** =yasnippet= @@ -801,10 +821,11 @@ This is good for auto indentation, folding, killing elements, apparently XPath?? Per-mode text expansion. What a lifechanger. #+BEGIN_SRC emacs-lisp - (use-package yasnippet - :config - (setq yas-snippet-dirs '("~/.emacs.d/snippets"))) - (yas-global-mode 1) + (unless (string-equal system-type "android") + (use-package yasnippet + :config + (setq yas-snippet-dirs '("~/.emacs.d/snippets"))) + (yas-global-mode 1)) #+END_SRC * Aesthetics @@ -816,11 +837,12 @@ Per-mode text expansion. What a lifechanger. Shows nice icons in the modeline and in =neotree=. Fonts need to be installed manually on Windows, possibly because of permissions issues or because of where the Emacs binary lives or maybe both those things. #+BEGIN_SRC emacs-lisp - (use-package all-the-icons - :config - (unless (iswin) - (when (not (member "all-the-icons" (font-family-list))) - (all-the-icons-install-fonts t)))) + (unless (string-equal system-type "android") + (use-package all-the-icons + :config + (unless (string-equal system-type "windows-nt") + (when (not (member "all-the-icons" (font-family-list))) + (all-the-icons-install-fonts t))))) #+END_SRC *** =emojify= @@ -828,10 +850,11 @@ Shows nice icons in the modeline and in =neotree=. Fonts need to be installed ma Support for various types of emoge. #+BEGIN_SRC emacs-lisp - (use-package emojify - :hook - (text-mode . emojify-mode) - (org-agenda-mode . emojify-mode)) + (unless (string-equal system-type "android") + (use-package emojify + :hook + (text-mode . emojify-mode) + (org-agenda-mode . emojify-mode))) #+END_SRC *** =hl-line= @@ -839,22 +862,20 @@ Support for various types of emoge. Highlights current line. #+BEGIN_SRC emacs-lisp - (use-package hl-line - :config - (global-hl-line-mode 1)) + (global-hl-line-mode 1) #+END_SRC ** Theme/colours -Set a theme from =modus-themes=. +Set a theme from =modus-themes=. This is built in for version 28 and above. #+BEGIN_SRC emacs-lisp - (use-package modus-themes - :config - (setq modus-themes-bold-constructs t) - (setq modus-themes-italic-constructs t) - (setq modus-themes-mixed-fonts t) - (setq modus-themes-org-blocks 'gray-background)) + (unless (string-equal system-type "android") + (use-package modus-themes)) + (setq modus-themes-bold-constructs t) + (setq modus-themes-italic-constructs t) + (setq modus-themes-mixed-fonts t) + (setq modus-themes-org-blocks 'gray-background) (load-theme 'modus-operandi-tinted t) #+END_SRC @@ -863,7 +884,8 @@ Set a theme from =modus-themes=. Use Noto fonts to match my system fonts on Linux. This has to be done differently on Windows for some reason. #+BEGIN_SRC emacs-lisp - (if (iswin) + (unless (string-equal system-type "android") + (if (string-equal system-type "windows-nt") (custom-set-faces '(default ((t (:family "Noto Mono" :foundry "outline" :slant normal :weight normal :height 98 :width normal)))) '(italic ((t (:slant italic)))) @@ -873,17 +895,18 @@ Use Noto fonts to match my system fonts on Linux. This has to be done differentl '(italic ((t (:slant italic)))) '(variable-pitch ((t (:family "Noto Sans" :height 90)))) '(fixed-pitch ((t (:family "Noto Mono" :height 100)))) - '(modus-themes-fixed-pitch ((t (:family "Noto Mono" :height 100)))))) + '(modus-themes-fixed-pitch ((t (:family "Noto Mono" :height 100))))))) #+END_SRC Use the =mixed-pitch= package to determine the font intelligently in modes that contain both text and prog elements. #+BEGIN_SRC emacs-lisp - (use-package mixed-pitch - :hook - (LaTeX-mode . mixed-pitch-mode) - (org-mode . mixed-pitch-mode) - (markdown-mode . mixed-pitch-mode)) + (unless (string-equal system-type "android") + (use-package mixed-pitch + :hook + (LaTeX-mode . mixed-pitch-mode) + (org-mode . mixed-pitch-mode) + (markdown-mode . mixed-pitch-mode))) #+END_SRC * Startup diff --git a/custom/dwpost.el b/custom/dwpost.el index 5aa9c8c..4d0a433 100644 --- a/custom/dwpost.el +++ b/custom/dwpost.el @@ -41,101 +41,109 @@ (with-current-buffer oldname (delete-file newname))) -(defun dwsecurity () - "Set security level for DW post" - (setq security (completing-read-multiple "Security (public, access, private): " '("public" "access" "private"))) - (if (not security) - (setq security "skip")) - (if (equal security "skip") - (sleep-for 0) +(unless (string-equal system-type "android") + (defun dwsecurity () + "Set security level for DW post" + (setq security (completing-read-multiple "Security (public, access, private): " '("public" "access" "private"))) + (if (not security) + (setq security "skip")) + (if (equal security "skip") + (sleep-for 0) (insert (concat "post-security: " - (let* ((securityjunk - (format "%S" security)) - (end (- (length securityjunk) 2))) - (substring securityjunk 2 end))"\n")))) + (let* ((securityjunk + (format "%S" security)) + (end (- (length securityjunk) 2))) + (substring securityjunk 2 end))"\n"))))) -(defun dwmood () - "Set mood for DW post" - (setq mood (completing-read-multiple "Mood: " '("accomplished" "aggravated" "amused" "angry" "annoyed" "anxious" "apathetic" "artistic" "awake" "bitchy" "blah" "blank" "bored" "bouncy" "busy" "calm" "cheerful" "chipper" "cold" "complacent" "confused" "contemplative" "content" "cranky" "crappy" "crazy" "creative" "crushed" "curious" "cynical" "depressed" "determined" "devious" "dirty" "disappointed" "discontent" "distressed" "ditzy" "dorky" "drained" "drunk" "ecstatic" "embarrassed" "energetic" "enraged" "enthralled" "envious" "exanimate" "excited" "exhausted" "flirty" "frustrated" "full" "geeky" "giddy" "giggly" "gloomy" "good" "grateful" "groggy" "grumpy" "guilty" "happy" "high" "hopeful" "horny" "hot" "hungry" "hyper" "impressed" "indescribable" "indifferent" "infuriated" "intimidated" "irate" "irritated" "jealous" "jubilant" "lazy" "lethargic" "listless" "lonely" "loved" "melancholy" "mellow" "mischievous" "moody" "morose" "naughty" "nauseated" "nerdy" "nervous" "nostalgic" "numb" "okay" "optimistic" "peaceful" "pensive" "pessimistic" "pissed off" "pleased" "predatory" "productive" "quixotic" "recumbent" "refreshed" "rejected" "rejuvenated" "relaxed" "relieved" "restless" "rushed" "sad" "satisfied" "scared" "shocked" "sick" "silly" "sleepy" "sore" "stressed" "surprised" "sympathetic" "thankful" "thirsty" "thoughtful" "tired" "touched" "uncomfortable" "weird" "working" "worried"))) - (if (not mood) - (setq mood "skip")) - (if (equal mood "skip") - (sleep-for 0) +(unless (string-equal system-type "android") + (defun dwmood () + "Set mood for DW post" + (setq mood (completing-read-multiple "Mood: " '("accomplished" "aggravated" "amused" "angry" "annoyed" "anxious" "apathetic" "artistic" "awake" "bitchy" "blah" "blank" "bored" "bouncy" "busy" "calm" "cheerful" "chipper" "cold" "complacent" "confused" "contemplative" "content" "cranky" "crappy" "crazy" "creative" "crushed" "curious" "cynical" "depressed" "determined" "devious" "dirty" "disappointed" "discontent" "distressed" "ditzy" "dorky" "drained" "drunk" "ecstatic" "embarrassed" "energetic" "enraged" "enthralled" "envious" "exanimate" "excited" "exhausted" "flirty" "frustrated" "full" "geeky" "giddy" "giggly" "gloomy" "good" "grateful" "groggy" "grumpy" "guilty" "happy" "high" "hopeful" "horny" "hot" "hungry" "hyper" "impressed" "indescribable" "indifferent" "infuriated" "intimidated" "irate" "irritated" "jealous" "jubilant" "lazy" "lethargic" "listless" "lonely" "loved" "melancholy" "mellow" "mischievous" "moody" "morose" "naughty" "nauseated" "nerdy" "nervous" "nostalgic" "numb" "okay" "optimistic" "peaceful" "pensive" "pessimistic" "pissed off" "pleased" "predatory" "productive" "quixotic" "recumbent" "refreshed" "rejected" "rejuvenated" "relaxed" "relieved" "restless" "rushed" "sad" "satisfied" "scared" "shocked" "sick" "silly" "sleepy" "sore" "stressed" "surprised" "sympathetic" "thankful" "thirsty" "thoughtful" "tired" "touched" "uncomfortable" "weird" "working" "worried"))) + (if (not mood) + (setq mood "skip")) + (if (equal mood "skip") + (sleep-for 0) (insert (concat "post-mood: " - (let* ((moodjunk - (format "%S" mood)) - (end (- (length moodjunk) 2))) - (substring moodjunk 2 end))"\n")))) + (let* ((moodjunk + (format "%S" mood)) + (end (- (length moodjunk) 2))) + (substring moodjunk 2 end))"\n"))))) -(defun dwmusic () - "Set current music for DW post" - (setq music (lastfm-user-get-recent-tracks :user lastfm-user :from 1 :to 1)) - (setq music (replace-regexp-in-string (regexp-quote "\" \"") " – " (format "%S" music) nil 'literal)) - (sleep-for 1) - (if (not music) - (setq music "nil")) - (if (equal music "nil") - (sleep-for 0) - (insert (concat "post-music: " - (let* ((musicjunk - (format "%S" music)) - (end (- (length musicjunk) 4))) - (substring musicjunk 4 end))"\n")))) +(unless (string-equal system-type "android") + (defun dwmusic () + "Set current music for DW post" + (setq music (lastfm-user-get-recent-tracks :user lastfm-user :from 1 :to 1)) + (setq music (replace-regexp-in-string (regexp-quote "\" \"") " – " (format "%S" music) nil 'literal)) + (sleep-for 1) + (if (not music) + (setq music "nil")) + (if (equal music "nil") + (sleep-for 0) + (insert (concat "post-music: " + (let* ((musicjunk + (format "%S" music)) + (end (- (length musicjunk) 4))) + (substring musicjunk 4 end))"\n"))))) -(defun dwicon (thefile) - "Set icon for DW post" - (setq icon "skip") - (load-file dw-iconfile) - (with-current-buffer thefile - (iconchoose)) - (if (equal icon "skip") - (sleep-for 0) - (insert (concat "post-icon: "icon "\n")))) +(unless (string-equal system-type "android") + (defun dwicon (thefile) + "Set icon for DW post" + (setq icon "skip") + (load-file dw-iconfile) + (with-current-buffer thefile + (iconchoose)) + (if (equal icon "skip") + (sleep-for 0) + (insert (concat "post-icon: "icon "\n"))))) -(defun dwlocation () - "Set location for DW post" - (setq location (read-string "Location: " dw-defaultlocation)) - (if (equal location "") - (sleep-for 0) - (insert (concat "post-location: " location "\n")))) +(unless (string-equal system-type "android") + (defun dwlocation () + "Set location for DW post" + (setq location (read-string "Location: " dw-defaultlocation)) + (if (equal location "") + (sleep-for 0) + (insert (concat "post-location: " location "\n"))))) -(defun dwmusic-manual () - "Set current music for DW post if lastfm.el not set up" - (setq music (read-string "Music: ")) - (if (equal music "") - (sleep-for 0) - (insert (concat "post-music: " music "\n")))) +(unless (string-equal system-type "android") + (defun dwmusic-manual () + "Set current music for DW post if lastfm.el not set up" + (setq music (read-string "Music: ")) + (if (equal music "") + (sleep-for 0) + (insert (concat "post-music: " music "\n"))))) -(defun dw-posted () - "Log DW post" - (find-file-noselect "~/Documents/drive/org/calendar/habit.org") - (with-current-buffer "habit.org" - (goto-char (point-min)) - (re-search-forward "RECUR dw posts") - (org-shiftright) - (sleep-for 1) - (save-buffer))) +(unless (string-equal system-type "android") + (defun dw-posted () + "Log DW post" + (find-file-noselect "~/Documents/drive/org/calendar/habit.org") + (with-current-buffer "habit.org" + (goto-char (point-min)) + (re-search-forward "RECUR dw posts") + (org-shiftright) + (sleep-for 4) + (save-buffer)))) -(defun dwpost (psubject tags) - "Post to DW" - (interactive (list (read-string "Post title (REQUIRED): ") - (read-string "Tags (comma-separated): "))) - (dwexport) - (compose-mail (concat dw-username "+" dw-pin "@post.dreamwidth.org") psubject) - (with-current-buffer (concat "*unsent mail to " dw-username "*") - (insert (concat "post-tags: org-export, " tags "\n")) - (dwsecurity) - (dwlocation) - (dwicon newname) - (cond - (lastfm-login t (dwmusic)) - ((dwmusic-manual))) - (dwmood) - (insert (concat "\n")) - (insert-file-contents newname) - (message-send-and-exit)) - (kill-buffer newname) - (kill-buffer (concat "*sent mail to " dw-username "*")) - (with-current-buffer oldname - (delete-file newname)) - (dw-posted)) +(unless (string-equal system-type "android") + (defun dwpost (psubject tags) + "Post to DW" + (interactive (list (read-string "Post title (REQUIRED): ") + (read-string "Tags (comma-separated): "))) + (dwexport) + (compose-mail (concat dw-username "+" dw-pin "@post.dreamwidth.org") psubject) + (with-current-buffer (concat "*unsent mail to " dw-username "*") + (insert (concat "post-tags: org-export, " tags "\n")) + (dwsecurity) + (dwlocation) + (dwicon newname) + (cond + (lastfm-login t (dwmusic)) + ((dwmusic-manual))) + (dwmood) + (insert (concat "\n")) + (insert-file-contents newname) + (message-send-and-exit)) + (kill-buffer newname) + (kill-buffer (concat "*sent mail to " dw-username "*")) + (with-current-buffer oldname + (delete-file newname)) + (dw-posted))) diff --git a/custom/fic.el b/custom/fic.el index fe24182..63ea39d 100644 --- a/custom/fic.el +++ b/custom/fic.el @@ -44,199 +44,200 @@ (with-current-buffer oldname (delete-file newname))) -(defun fic-export () - "Export fic to HTML, EPUB, PDF" - (interactive) - (shell-command "cp ~/.emacs.d/fic-export-files/FFXYevon.ttf .") - (setq asal (y-or-n-p "ASAL?")) - (if asal +(unless (string-equal system-type "android") + (defun fic-export () + "Export fic to HTML, EPUB, PDF" + (interactive) + (shell-command "cp ~/.emacs.d/fic-export-files/FFXYevon.ttf .") + (setq asal (y-or-n-p "ASAL?")) + (if asal + (progn + (setq title t) + (setq multichapter t) + (setq chaptertitles nil) + (setq ffx t)) (progn - (setq title t) - (setq multichapter t) - (setq chaptertitles nil) - (setq ffx t)) - (progn - (setq title (y-or-n-p "Use the fic title in exports?")) - (setq multichapter (y-or-n-p "Multichapter?")) - (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)) - (while (re-search-forward "\\[fn:\\([0-9]*\\):\\(.*\\)\\]" nil t) - (replace-match "@@html:\\2@@@@latex:\\\\footnote{\\2}@@")) - (let ((user-full-name "ovely") - (org-html-head "")) - (org-html-export-to-html) - (org-latex-export-to-latex)) - (revert-buffer t t) - (setq htmlfile (concat (file-name-base) ".html")) - (find-file-noselect htmlfile) - (with-current-buffer htmlfile - (goto-char (point-min)) - (while (re-search-forward "
\n
" nil t) - (replace-match "\n")) - (goto-char (point-min)) - (while (re-search-forward "
\n\n

" nil t) - (replace-match "\n

\n

")) - (goto-char (point-min)) - (while (re-search-forward "


\n\n

" nil t) - (replace-match "

\n
\n

")) - (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 "

Validate

" nil t) - (replace-match "")) - (goto-char (point-min)) - (while (re-search-forward "
" nil t) - (replace-match "")) - (goto-char (point-min)) - (while (re-search-forward "section-number-2\">\\([0-9]*\\)<" nil t) - (replace-match "section-number-2\">\\1\.<")) - (goto-char (point-min)) - (while (re-search-forward "

" nil t) - (replace-match "")) + (setq title (y-or-n-p "Use the fic title in exports?")) + (setq multichapter (y-or-n-p "Multichapter?")) + (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)) - (while (re-search-forward "\n\n" nil t) - (replace-match "\n\n")) - (if (not title) + (while (re-search-forward "\\[fn:\\([0-9]*\\):\\(.*\\)\\]" nil t) + (replace-match "@@html:\\2@@@@latex:\\\\footnote{\\2}@@")) + (let ((user-full-name "ovely") + (org-html-head "")) + (org-html-export-to-html) + (org-latex-export-to-latex)) + (revert-buffer t t) + (setq htmlfile (concat (file-name-base) ".html")) + (find-file-noselect htmlfile) + (with-current-buffer htmlfile + (goto-char (point-min)) + (while (re-search-forward "

\n
" nil t) + (replace-match "
\n
")) + (goto-char (point-min)) + (while (re-search-forward "
\n\n

" nil t) + (replace-match "\n

\n

")) + (goto-char (point-min)) + (while (re-search-forward "


\n\n

" nil t) + (replace-match "

\n
\n

")) + (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 "

Validate

" nil t) + (replace-match "")) + (goto-char (point-min)) + (while (re-search-forward "
" nil t) + (replace-match "")) + (goto-char (point-min)) + (while (re-search-forward "section-number-2\">\\([0-9]*\\)<" nil t) + (replace-match "section-number-2\">\\1\.<")) + (goto-char (point-min)) + (while (re-search-forward "

" nil t) + (replace-match "")) + (goto-char (point-min)) + (while (re-search-forward "\n\n" nil t) + (replace-match "\n\n")) + (if (not title) + (progn + (goto-char (point-min)) + (while (re-search-forward "" nil t) + (replace-match "")))) (progn (goto-char (point-min)) - (while (re-search-forward "" nil t) - (replace-match "")))) - (progn - (goto-char (point-min)) - (while (re-search-forward "