Skip to content

Latest commit

 

History

History
118 lines (103 loc) · 4.47 KB

starter-kit-text.org

File metadata and controls

118 lines (103 loc) · 4.47 KB

Starter Kit Text Editing

This is part of the Emacs Starter Kit.

This file provides settings for text-editing modes and formats, including Markdown and Pandoc, as well as spellchecking and line-wrapping.

Install Text packages

(setq install-packages (list 'smooth-scrolling 'smartparens 'deft))
(dolist (package install-packages) (package-install package))

Text Management and Appearance

Line wrapping and position

Sane line wrapping and scrolling for long documents and papers. Plus a function for removing any hard-returns in a document.

(when (fboundp 'adaptive-wrap-prefix-mode)
  (defun my-activate-adaptive-wrap-prefix-mode ()
    "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
    (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
  (add-hook 'visual-line-mode-hook 'my-activate-adaptive-wrap-prefix-mode))
  (global-visual-line-mode t)

  ;;; prefer auto-fill to visual line wrap in ESS mode
  (add-hook 'ess-mode-hook 'turn-on-auto-fill)
  (add-hook 'inferior-ess-mode-hook 'turn-on-auto-fill)

  ;;; but turn off auto-fill in tex and markdown
  (add-hook 'markdown-mode-hook 'turn-off-auto-fill)
  (add-hook 'latex-mode-hook 'turn-off-auto-fill)

  ;;; unfill paragraph
  (defun unfill-paragraph ()
  (interactive)
  (let ((fill-column (point-max)))
  (fill-paragraph nil)))
  (global-set-key (kbd "<f6>") 'unfill-paragraph)

  ;; smooth-scrolling
  (require 'smooth-scrolling)

  ;; more smooth efforts.
  (setq-default scroll-conservatively 0
                scroll-up-aggressively 0.01
                scroll-down-aggressively 0.01)

Spelling

Use aspell instead of ispell. Turned off here because it loads too late. I had to put it in starter-kit-aspell.org.

(setq ispell-program-name "aspell"
     ispell-dictionary "english"
     ispell-dictionary-alist
     (let ((default '("[A-Za-z]" "[^A-Za-z]" "[']" nil
                      ("-B" "-d" "english")
                      nil iso-8859-1)))
       `((nil ,@default)
         ("english" ,@default))))

   ;; ispell --- make ispell skip \citep, \citet etc in .tex files.
   (setq ispell-tex-skip-alists
   '((;;("%\\[" . "%\\]") ; AMStex block comment...
   ;; All the standard LaTeX keywords from L. Lamport's guide:
   ;; \cite, \hspace, \hspace*, \hyphenation, \include, \includeonly, \input,
   ;; \label, \nocite, \rule (in ispell - rest included here)
   ("\\\\addcontentsline"              ispell-tex-arg-end 2)
   ("\\\\add\\(tocontents\\|vspace\\)" ispell-tex-arg-end)
   ("\\\\\\([aA]lph\\|arabic\\)"   ispell-tex-arg-end)
   ("\\\\author"                         ispell-tex-arg-end)
   ;; New regexps here --- kjh
   ("\\\\\\(text\\|paren\\)cite" ispell-tex-arg-end)
   ("\\\\cite\\(t\\|p\\|year\\|yearpar\\)" ispell-tex-arg-end)
   ("\\\\bibliographystyle"                ispell-tex-arg-end)
   ("\\\\makebox"                  ispell-tex-arg-end 0)
   ("\\\\e?psfig"                  ispell-tex-arg-end)
   ("\\\\document\\(class\\|style\\)" .
   "\\\\begin[ \t\n]*{[ \t\n]*document[ \t\n]*}"))
   (;; delimited with \begin.  In ispell: displaymath, eqnarray, eqnarray*,
   ;; equation, minipage, picture, tabular, tabular* (ispell)
   ("\\(figure\\|table\\)\\*?"     ispell-tex-arg-end 0)
   ("list"                                 ispell-tex-arg-end 2)
   ("program"             . "\\\\end[ \t\n]*{[ \t\n]*program[ \t\n]*}")
   ("verbatim\\*?"        . "\\\\end[ \t\n]*{[ \t\n]*verbatim\\*?[ \t\n]*}"))))

Smartparens Mode. Smart autopairing of quotes and parentheses.

(smartparens-global-mode 1)
(require 'smartparens-config)
(show-smartparens-global-mode +1)

Deft mode helps organize folders of text notes.

#+srcname deft-mode

(require 'deft)
(setq deft-extensions '("org" "md", "markdown", "Markdown", "mdown", "txt"))
(setq deft-directory "~/Templates/Dropbox/Org")
(setq deft-recursive t)
(setq deft-use-filename-as-title t)
(setq deft-markdown-mode-title-level 2)
(setq deft-org-mode-title-prefix t)
(global-set-key (kbd "C-x C-g") 'deft-find-file)
(message "------ Starter Kit Text loaded ------")