diff options
Diffstat (limited to 'emacs/work_inits/23-text-related.el')
| -rw-r--r-- | emacs/work_inits/23-text-related.el | 175 |
1 files changed, 175 insertions, 0 deletions
diff --git a/emacs/work_inits/23-text-related.el b/emacs/work_inits/23-text-related.el new file mode 100644 index 0000000..8aac63e --- /dev/null +++ b/emacs/work_inits/23-text-related.el @@ -0,0 +1,175 @@ +;; Time-stamp: <2020-05-17 15:35:55 (tslil@bison)> + +;; ----------------------------------------------------------------------------- +;; Spelling + +(use-package spell-fu + :ensure t + :config + (setq ispell-dictionary "en_GB-ise-w_accents" + ispell-personal-dictionary "~/.aspell.en.pws") + + ;; The default was this "\\b\\([[:alpha:]][[:alpha:]']*\\)\\b", but that + ;; didn't play well with ``LaTeX's quoting system''. + (setq-default spell-fu-word-regexp "\\([[:alpha:]]+\\('[[:alpha:]]+\\)*\\)" + spell-fu-faces-exclude '(font-latex-math-face + font-latex-sedate-face + font-lock-keyword-face + font-lock-function-name-face + font-lock-variable-name-face))) + +;; (defun flyspell-correct-selectrum (candidates word) +;; (let* ((save "[SAVE]") +;; (accept-session "[ACCEPT (session)]") +;; (accept-buffer "[ACCEPT (buffer)]") +;; (skip "[SKIP]") +;; (selectrucm-should-sort nil) +;; (result (selectrum-completing-read +;; (format "Correcting '%s': " word) +;; (append candidates +;; (list save accept-session accept-buffer skip))))) +;; (cond +;; ((string= result save) +;; (cons 'save word)) +;; ((string= result accept-session) +;; (cons 'session word)) +;; ((string= result accept-buffer) +;; (cons 'buffer word)) +;; ((string= result skip) +;; (cons 'skip word)) +;; (t +;; result)))) + +;; (use-package flyspell-correct +;; :ensure t +;; :defer t +;; :config +;; (setq flyspell-correct-interface #'flyspell-correct-selectrum)) + +;; (use-package flyspell +;; :ensure t +;; :bind (:map flyspell-mode-map +;; ("M-$" . flyspell-correct-wrapper) +;; ("C-," . nil) +;; ("C-." . nil) +;; ("C-\"" . nil)) +;; :init +;; (setq ispell-dictionary "british" +;; flyspell-default-dictionary "british")) + +(setq sentence-end-double-space nil) + +(add-hook 'mail-mode-hook (lambda () + (electric-pair-local-mode 1) + (turn-on-auto-fill) + (spell-fu-mode 1) + ;; (flyspell-mode 1) + (company-mode 1))) + +(add-hook 'text-mode-hook (lambda () + ;; (set-input-method "Adga") + (subword-mode 1) + (electric-pair-local-mode 1) + (turn-on-auto-fill) + (siege-mode 1) + (spell-fu-mode 1) + ;; (flyspell-mode 1) + )) + +(use-package dictionary :ensure t :defer t) + +;; ----------------------------------------------------------------------------- +;; Org + +(use-package org + :defer t + :bind (:map org-mode-map + ("M-h" . nil)) + ;; :hook (org-mode . (lambda () + ;; (activate-input-method default-input-method))) + :config + (setq org-use-sub-superscripts (quote {}) + org-modules nil)) + + +;; ----------------------------------------------------------------------------- +;; Deft + +(use-package deft + :ensure t + :defer t + :commands (deft) + :bind (("C-c C-z" . deft)) + :config + (setq deft-default-extension "org" + deft-directory "~/store/notes" + deft-use-filename-as-title nil + deft-use-filter-string-for-filename t + deft-file-naming-rules '((noslash . "_") + (nospace . "_") + (case-fn . downcase)) + deft-org-mode-title-prefix t) + + ;; (defvar deft-take-note-pre-grab + ;; '((region-thing . (let ((r (if (region-active-p) + ;; (buffer-substring (region-beginning) (region-end)) + ;; (thing-at-point 'line)))) + ;; (if r (concat r "\n") ""))) + ;; (bfn . (let ((f (buffer-file-name)) + ;; (b (buffer-name))) (if f f (concat b " (no file associated)"))))) + ;; "List of pairs of symbol names and (functions evaluating to) + ;; strings evaluated before the buffer is created, and made + ;; available for deft-take-note-default-contents.") + + ;; (defvar deft-take-note-post-grab '() + ;; "List of pairs of symbol names and (functions evaluating to) + ;; strings evaluated after the buffer is created, and made + ;; available for deft-take-note-default-contents.") + + ;; (defvar deft-take-note-default-contents '(region-thing bfn "\n") + ;; "List with string literals and symbols defined in the pre and + ;; post grab lists to be inserted into the buffer.") + + ;; (defun deft-take-note () + ;; (interactive) + ;; (let ((pre-alist (mapcar #'(lambda (elt) `(,(car elt) . ,(eval (cdr elt)))) + ;; deft-take-note-pre-grab))) + ;; (let ((bn (concat (format-time-string "%Y%m%d-%H:%M:%S.%N-%Z") "." + ;; deft-default-extension))) + ;; (switch-to-buffer bn) + ;; (set-visited-file-name (expand-file-name + ;; (concat deft-directory "/" bn))) + ;; (let ((complete-alist + ;; (append pre-alist + ;; (mapcar #'(lambda (elt) `(,(car elt) . ,(eval (cdr elt)))) + ;; deft-take-note-post-grab)))) + ;; (mapc #'(lambda (elt) (if (eq (type-of elt) 'string) + ;; (insert elt) + ;; (insert (cdr (assoc elt complete-alist))))) + ;; deft-take-note-default-contents))))) + ) + +;; ----------------------------------------------------------------------------- +;; Useful keybinds + +(defun vi-open-line-above () + "Insert a newline above the current line and put point at beginning." + (interactive) + (unless (bolp) + (beginning-of-line)) + (newline) + (forward-line -1) + (indent-according-to-mode)) + +(defun vi-open-line-below () + "Insert a newline below the current line and put point at beginning." + (interactive) + (unless (eolp) + (end-of-line)) + (newline-and-indent)) + +(global-set-key (kbd "M-o") 'vi-open-line-below) +(global-set-key (kbd "C-o") 'vi-open-line-above) + +(global-set-key (kbd "M-C-+") 'text-scale-increase) +(global-set-key (kbd "M-C--") 'text-scale-decrease) |
