Skip to content

Latest commit

 

History

History
231 lines (169 loc) · 7.53 KB

starter-kit-text.org

File metadata and controls

231 lines (169 loc) · 7.53 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.

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)

;;; original code by Kieran Healy
    ;;; 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 for me the auto-fill mode is causing disruption in interactive stata and r sessions so I turn it off.
        ;;    (add-hook 'ess-mode-hook 'turn-off-auto-fill)
        ;;    (add-hook 'inferior-ess-mode-hook 'turn-off-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)

    ;; from Sacha chua's config
    ;; she says:  =visual-line-mode= is so much better than =auto-fill-mode=. It doesn't actually break the text into ;; multiple lines - it only looks that way.

    (remove-hook 'text-mode-hook #'turn-on-auto-fill) 
    (add-hook 'text-mode-hook 'turn-on-visual-line-mode)

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

Deft

Deft mode helps organize folders of text notes.

#+srcname deft-mode

(use-package deft
  :bind ("s-'" . deft-find-file)
  :defer t
  :config
  (setq deft-extensions '("org" "txt" "tex" "Rnw" "md" "markdown")
        deft-directory "~/documents/dropbox/notes"
        deft-recursive t
        deft-use-filename-as-title t
        deft-markdown-mode-title-level 2
        deft-org-mode-title-prefix t)
  (add-to-list 'auto-mode-alist '("/deft/.*\\.txt\\'" . org)))

;; (global-set-key (kbd "s-'") 'deft-find-file)
;; (global-set-key (kbd "s--") 'deft)
;; (global-set-key  (kbd "C-c d") 'deft)

CSV mode

View and edit CSV files. See the CSV mode homepage for more details. From the readme:

In CSV mode, the following commands are available:

  • C-c C-s (`csv-sort-fields’) and C-c C-n (`csv-sort-numeric-fields’) respectively sort lexicographically and numerically on a specified field or column.
  • C-c C-r (`csv-reverse-region’) reverses the order. (These commands are based closely on, and use, code in `sort.el’.)
  • C-c C-k (`csv-kill-fields’) and C-c C-y (`csv-yank-fields’) kill and yank fields or columns, although they do not use the normal kill ring. C-c C-k can kill more than one field at once, but multiple killed fields can be yanked only as a fixed group equivalent to a single field.
  • C-c C-a (`csv-align-fields’) aligns fields into columns
  • C-c C-u (`csv-unalign-fields’) undoes such alignment; separators can be hidden within aligned records.
  • C-c C-t (`csv-transpose’) interchanges rows and columns. For details, see the documentation for the individual commands.

#+srcname csv-mode

(add-to-list 'auto-mode-alist '("\\.[Cc][Ss][Vv]\\'" . csv-mode))
(autoload 'csv-mode "csv-mode"
  "Major mode for editing comma-separated value files." t)

Bit originally under custom-set-variables

(setq text-mode-hook (quote (text-mode-hook-identify)))

Sentences end with a single space

In my world, sentences end with a single space. This makes sentence navigation commands work for me.

… but i’m not sure…

(setq sentence-end-double-space nil)

Killing text

From https://github.com/itsjeyd/emacs-config/blob/emacs24/init.el

(defadvice kill-region (before slick-cut activate compile)
  "When called interactively with no active region, kill a single line instead."
  (interactive
   (if mark-active (list (region-beginning) (region-end))
     (list (line-beginning-position)
           (line-beginning-position 2)))))

Typing

Typing of Emacs

(use-package typing
  :defer t
  :init
  (autoload 'typing-of-emacs "typing" nil t)
  :config
  (progn
    (setq toe-starting-length 6)
    (setq toe-starting-time-per-word 2)
    (setq toe-max-length 20)))

Provide

(provide 'starter-kit-text)

Final message

(message "Starter Kit Text File loaded.")