<commit_before>#+startup: indent hidestars

#+title: Emacs Configuration
#+author: <NAME>

* IDO Mode
Ido-mode is a great way to show the file path when searching.

#+BEGIN_SRC emacs-lisp
(require 'ido)
(ido-mode t)

(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)

#+END_SRC
* Scrolling

For now, I'm going to leave this blank. I'll decide how I want Emacs to handle my scrolling of text.

* Spell Check
I use =flyspell= for spell check. the command is C-; to check the
previous word. If it does not autocorrect with the correct word, you
can run the command again.

#+BEGIN_SRC emacs-lisp
  (use-package flyspell
    :ensure t
    :defer t
    :init
    (progn
      (add-hook 'prog-mode-hook 'flyspell-prog-mode)
      (add-hook 'text-mode-hook 'flyspell-mode)
      )
    :config
    ;; Sets flyspell correction to use two-finger mouse click
    (define-key flyspell-mouse-map [down-mouse-3] #'flyspell-correct-word)
    )

  ;; This tells Emacs were to find ispell when using the Mac
  (setq ispell-program-name "/usr/local/bin/ispell")

#+END_SRC

* AuCTeX
If you're going to write LaTeX files on Emacs, AucTeX is the Gold Standard. No sense in trying anything else. One challenge that I had while setting up AuCTeX is that with Mac OSX El Cap, Emacs can have trouble finding the TeX distribution. I found very useful code from [[http://www.qqyang.org/blog/not-complete-guide-to-basictex/][Qingqing Yang's blog]]

#+BEGIN_SRC emacs-lisp
(let (
      (my-paths
       '("~/bin"
         "/usr/local/bin"
         "/usr/bin"
         "/Library/TeX/texbin" ; add path to basictex bin
         "/usr/texbin" ; add path to basictex bin
         "/bin"
         )))

  (setenv "PATH" (concat (getenv "PATH") ":"
                         (mapconcat 'identity my-paths ":")))
  (setq exec-path (append my-paths (list "." exec-directory))))
#+END_SRC

I actually don't know what the below code does. I'm writing this note to myself so that I make sure to figure it out, and then to modify or delete it as needed.

#+BEGIN_SRC emacs-lisp :results silent

(use-package tex-site
  :ensure auctex
  :config
  (add-hook 'LaTeX-mode-hook #'LaTeX-math-mode)
  (setq TeX-auto-save nil ; remove "/auto/" file generation
        TeX-parse-self t
        reftex-plug-into-AUCTeX t)
  (add-hook 'LaTeX-mode-hook #'TeX-PDF-mode)
  (setq TeX-source-correlate-method 'synctex)
  (setq TeX-source-correlate-mode t)
  (eval-after-load "tex"
    '(add-to-list 'TeX-command-list '("latexmk" "latexmk -synctex=1 -shell-escape -pdf %s" TeX-run-TeX nil t :help "Process file with latexmk"))
    )
  (eval-after-load "tex"
    '(add-to-list 'TeX-command-list '("xelatexmk" "latexmk -synctex=1 -shell-escape -xelatex %s" TeX-run-TeX nil t :help "Process file with xelatexmk"))
    )
  (add-hook 'TeX-mode-hook (lambda () (setq TeX-command-default "latexmk"))))
#+END_SRC
* RefTeX
I want to be sure that RefTeX loads whenever I am working on a TeX document. I figured out the code from [[https://emacs.stackexchange.com/questions/34189/emacs-setup-for-latex-after-use-package-verse][Stack Exchange.]] (NB: There's mode code in the answer suggesting key bindings for GREP searching the document. Might be worth looking into.)

#+BEGIN_SRC emacs-lisp :results silent
;; Set RefTeX to load automatically with AUCTeX
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)

#+END_SRC

Our next task is setting up a global bibliography so that RefTeX knows where to look when invoking the command for citations. Many people are fond of listing that setting the global bibliographies can be a list but it was difficult to find an example of what that looked like. I actually use two different =.bib= files, one for books and articles (my references) and another for primary sources (archival research). Many thanks to [[https://github.com/tmalsburg/helm-bibtex][Titus von der Malsburg's GitHub]] for showing how it's done.

#+BEGIN_SRC emacs-lisp :results silent
;; So that RefTeX finds my bibliography
(setq reftex-default-bibliography
      '("~/Dropbox/AcademicWork/Bibs/refs.bib"
        "~/Dropbox/AcademicWork/Bibs/primary.bib"))

#+END_SRC

The default setting for RefTeX is to use =\cite{key}= when inserting citations. Because I use Biblatex-Chicago for nearly all my writing, I need to make changes to how the citation keys are generated. Here I am thankful to a post [[https://tex.stackexchange.com/questions/31966/setting-up-reftex-with-biblatex-citation-commands][Stack Exchange and the answer by Aaron]].

#+BEGIN_SRC emacs-lisp :results silent
(eval-after-load 'reftex-vars
  '(progn
     ;; (also some other reftex-related customizations)
     (setq reftex-cite-format
           '((?\C-m . "\\cite[]{%l}")
             (?f . "\\footcite[][]{%l}")
             (?t . "\\textcite[?]{%l}")
             (?p . "\\parencite[]{%l}")
             (?a . "\\autocite[?]{%l}.")
             (?n . "\\nocite{%l}")))))
#+END_SRC

* Org-Mode

Org-Mode is the primary way that I should be writing. In this section, we need to add some settings that make things easier to manage, export, and the like. In previous setups of my =.emacs= configuration, I did not organize these as well as I could have. So here, I'm going to include the settings relevant to each mode or feature. More information can be found via the org-mode manual: I prefer the pdf [[http://orgmode.org/org.pdf][found here]]. 

It bears mentioning that if I ever want to check my org-mode verison, I can use =M-x org-version=. 

** Exporting

#+BEGIN_SRC emacs-lisp :results silent

(require 'ox-md)
(require 'ox-beamer)
(require 'ox-latex)

#+END_SRC

** Capture
*** Key-bindings
Make a key-binding to my notes file.

The point with these hot-keys is to make short-cuts to several org files while I will use for notetaking. Ideally, I'd like to do this with markdown. Although Org-mode is much more powerful than markdown, I am partial to the option of keeping unique independent markdown files for each idea rather than a cluster of =.org= files. Still, this is helpful as it helps me thinkthrough how that might work. <commit_msg>updated org-mode config from Howard Abrams<commit_after>#+startup: indent hidestars

#+title: Emacs Configuration
#+author: <NAME>

* IDO Mode
Ido-mode is a great way to show the file path when searching.

#+BEGIN_SRC emacs-lisp
(require 'ido)
(ido-mode t)

(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)

#+END_SRC
* Scrolling

For now, I'm going to leave this blank. I'll decide how I want Emacs to handle my scrolling of text.

* Spell Check
I use =flyspell= for spell check. the command is C-; to check the
previous word. If it does not autocorrect with the correct word, you
can run the command again.

#+BEGIN_SRC emacs-lisp
  (use-package flyspell
    :ensure t
    :defer t
    :init
    (progn
      (add-hook 'prog-mode-hook 'flyspell-prog-mode)
      (add-hook 'text-mode-hook 'flyspell-mode)
      )
    :config
    ;; Sets flyspell correction to use two-finger mouse click
    (define-key flyspell-mouse-map [down-mouse-3] #'flyspell-correct-word)
    )

  ;; This tells Emacs were to find ispell when using the Mac
  (setq ispell-program-name "/usr/local/bin/ispell")

#+END_SRC

* AuCTeX
If you're going to write LaTeX files on Emacs, AucTeX is the Gold Standard. No sense in trying anything else. One challenge that I had while setting up AuCTeX is that with Mac OSX El Cap, Emacs can have trouble finding the TeX distribution. I found very useful code from [[http://www.qqyang.org/blog/not-complete-guide-to-basictex/][Qingqing Yang's blog]]

#+BEGIN_SRC emacs-lisp
(let (
      (my-paths
       '("~/bin"
         "/usr/local/bin"
         "/usr/bin"
         "/Library/TeX/texbin" ; add path to basictex bin
         "/usr/texbin" ; add path to basictex bin
         "/bin"
         )))

  (setenv "PATH" (concat (getenv "PATH") ":"
                         (mapconcat 'identity my-paths ":")))
  (setq exec-path (append my-paths (list "." exec-directory))))
#+END_SRC

I actually don't know what the below code does. I'm writing this note to myself so that I make sure to figure it out, and then to modify or delete it as needed.

#+BEGIN_SRC emacs-lisp :results silent

(use-package tex-site
  :ensure auctex
  :config
  (add-hook 'LaTeX-mode-hook #'LaTeX-math-mode)
  (setq TeX-auto-save nil ; remove "/auto/" file generation
        TeX-parse-self t
        reftex-plug-into-AUCTeX t)
  (add-hook 'LaTeX-mode-hook #'TeX-PDF-mode)
  (setq TeX-source-correlate-method 'synctex)
  (setq TeX-source-correlate-mode t)
  (eval-after-load "tex"
    '(add-to-list 'TeX-command-list '("latexmk" "latexmk -synctex=1 -shell-escape -pdf %s" TeX-run-TeX nil t :help "Process file with latexmk"))
    )
  (eval-after-load "tex"
    '(add-to-list 'TeX-command-list '("xelatexmk" "latexmk -synctex=1 -shell-escape -xelatex %s" TeX-run-TeX nil t :help "Process file with xelatexmk"))
    )
  (add-hook 'TeX-mode-hook (lambda () (setq TeX-command-default "latexmk"))))
#+END_SRC
* RefTeX
I want to be sure that RefTeX loads whenever I am working on a TeX document. I figured out the code from [[https://emacs.stackexchange.com/questions/34189/emacs-setup-for-latex-after-use-package-verse][Stack Exchange.]] (NB: There's mode code in the answer suggesting key bindings for GREP searching the document. Might be worth looking into.)

#+BEGIN_SRC emacs-lisp :results silent
;; Set RefTeX to load automatically with AUCTeX
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)

#+END_SRC

Our next task is setting up a global bibliography so that RefTeX knows where to look when invoking the command for citations. Many people are fond of listing that setting the global bibliographies can be a list but it was difficult to find an example of what that looked like. I actually use two different =.bib= files, one for books and articles (my references) and another for primary sources (archival research). Many thanks to [[https://github.com/tmalsburg/helm-bibtex][Titus von der Malsburg's GitHub]] for showing how it's done.

#+BEGIN_SRC emacs-lisp :results silent
;; So that RefTeX finds my bibliography
(setq reftex-default-bibliography
      '("~/Dropbox/AcademicWork/Bibs/refs.bib"
        "~/Dropbox/AcademicWork/Bibs/primary.bib"))

#+END_SRC

The default setting for RefTeX is to use =\cite{key}= when inserting citations. Because I use Biblatex-Chicago for nearly all my writing, I need to make changes to how the citation keys are generated. Here I am thankful to a post [[https://tex.stackexchange.com/questions/31966/setting-up-reftex-with-biblatex-citation-commands][Stack Exchange and the answer by Aaron]].

#+BEGIN_SRC emacs-lisp :results silent
(eval-after-load 'reftex-vars
  '(progn
     ;; (also some other reftex-related customizations)
     (setq reftex-cite-format
           '((?\C-m . "\\cite[]{%l}")
             (?f . "\\footcite[][]{%l}")
             (?t . "\\textcite[?]{%l}")
             (?p . "\\parencite[]{%l}")
             (?a . "\\autocite[?]{%l}.")
             (?n . "\\nocite{%l}")))))
#+END_SRC

* Org-Mode

Org-Mode is the primary way that I should be writing. In this section, we need to add some settings that make things easier to manage, export, and the like. In previous setups of my =.emacs= configuration, I did not organize these as well as I could have. So here, I'm going to include the settings relevant to each mode or feature. More information can be found via the org-mode manual: I prefer the pdf [[http://orgmode.org/org.pdf][found here]]. 

It bears mentioning that if I ever want to check my org-mode verison, I can use =M-x org-version=. 
** "Word Processor
[[http://www.howardism.org/Technical/Emacs/orgmode-wordprocessor.html][Howardism]] has the good on setting up Org-Mode to work like a word processor.
#+BEGIN_SRC emacs-lisp :results silent
; remove slashes when presenting italice
(setq org-hide-emphasis-markers t)

#+END_SRC

** Exporting

#+BEGIN_SRC emacs-lisp :results silent

(require 'ox-md)
(require 'ox-beamer)
(require 'ox-latex)

#+END_SRC

** Capture
*** Key-bindings
Make a key-binding to my notes file.

The point with these hot-keys is to make short-cuts to several org files while I will use for notetaking. Ideally, I'd like to do this with markdown. Although Org-mode is much more powerful than markdown, I am partial to the option of keeping unique independent markdown files for each idea rather than a cluster of =.org= files. Still, this is helpful as it helps me thinkthrough how that might work. 
{'fraction_non_alphanumeric': 0.11187250996015936, 'fraction_numerical': 0.0022310756972111555, 'mean_word_length': 3.434982332155477, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6379534', 'n_tokens_mistral': 4235, 'n_tokens_neox': 4022, 'n_words': 1540}