]> git.donarmstrong.com Git - lib.git/blobdiff - emacs_el/configuration/don-configuration.org
add flycheck
[lib.git] / emacs_el / configuration / don-configuration.org
index 854cbe7b00fccb19c73246b58b2ae388c5fe4105..6235cc871256b51bf0d5be3082728b4e4bd7ee6a 100644 (file)
@@ -1,4 +1,5 @@
 #+PROPERTY: header-args:emacs-lisp :tangle don-configuration.el
+#+OPTIONS: auto-id:f
 * Load debugger
 
 # if for some reason, things get pear-shaped, we want to be able to
@@ -7,6 +8,25 @@
 #+BEGIN_SRC emacs-lisp
 (setq debug-on-event 'siguser2)
 #+END_SRC
+* Paths
+** Update PATH
+#+BEGIN_SRC emacs-lisp
+  (add-to-list 'exec-path '"/usr/local/bin")
+  (add-to-list 'exec-path '"~/bin/")
+#+END_SRC
+** Add library paths
+#+BEGIN_SRC emacs-lisp
+(eval-when-compile
+  (let ((default-directory "~/var/emacs/elpa"))
+    (normal-top-level-add-subdirs-to-load-path))
+  )
+(add-to-list 'load-path '"~/lib/emacs_el/")
+(let ((default-directory "~/lib/emacs_el/"))
+  (normal-top-level-add-subdirs-to-load-path))
+(let ((default-directory "~/var/emacs/elpa"))
+  (normal-top-level-add-subdirs-to-load-path))
+(setq package-user-dir "~/var/emacs/elpa")
+#+END_SRC
 * Initial startup stuff
 ** Disable startup screen
 #+BEGIN_SRC emacs-lisp
 #+END_SRC
 * Package management
 ** package repositories and package manager
-Borrowed from https://github.com/nilcons/emacs-use-package-fast/ to
-load  [[https://github.com/jwiegley/use-package/][use-package]] even faster
-#+BEGIN_SRC emacs-lisp
-  (eval-and-compile
-    ;; add /etc/ssl/ca-global/ca-certificates.crt so that we can
-    ;; download packages when we're on Debian hosts which chop down the
-    ;; list of available certificates
-    (require 'gnutls)
-    (add-to-list 'gnutls-trustfiles "/etc/ssl/ca-global/ca-certificates.crt")
-    (setq package-enable-at-startup nil)
-    (setq package--init-file-ensured t)
-    (setq package-user-dir "~/var/emacs/elpa")
-    (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
-                             ("melpa" . "https://melpa.org/packages/")
-                             ("org" . "http://orgmode.org/elpa/")))
-    (setq use-package-verbose (not (bound-and-true-p byte-compile-current-file))))
-  (mapc #'(lambda (add) (add-to-list 'load-path add))
-    (eval-when-compile
-      (package-initialize)
-      (unless (package-installed-p 'use-package)
-        (package-refresh-contents)
-        (package-install 'use-package))
-      (let ((package-user-dir-real (file-truename package-user-dir)))
-        ;; The reverse is necessary, because outside we mapc
-        ;; add-to-list element-by-element, which reverses.
-        (nreverse (apply #'nconc
-                 ;; Only keep package.el provided loadpaths.
-                 (mapcar #'(lambda (path)
-                     (if (string-prefix-p package-user-dir-real path)
-                         (list path)
-                       nil))
-                     load-path))))))
-
-  ;;; fix up info paths for packages
-  (with-eval-after-load "info"
-    (info-initialize)
-    (dolist (dir (directory-files package-user-dir))
-      (let ((fdir (concat (file-name-as-directory package-user-dir) dir)))
-        (unless (or (member dir '("." ".." "archives" "gnupg"))
-                    (not (file-directory-p fdir))
-                    (not (file-exists-p (concat (file-name-as-directory fdir) "dir"))))
-          (add-to-list 'Info-directory-list fdir)))))
-
-
-  (eval-when-compile
-    (require 'use-package))
-  (require 'bind-key)
-  (require 'diminish)
+#+BEGIN_SRC emacs-lisp
+  (require 'use-package)
+(require 'gnutls)
+  (add-to-list 'gnutls-trustfiles "/etc/ssl/ca-global/ca-certificates.crt")
+  (setq package-enable-at-startup nil)
+  (setq package--init-file-ensured t)
+  (setq package-user-dir "~/var/emacs/elpa")
+  (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
+                          ("melpa" . "https://melpa.org/packages/")
+                          ("org" . "http://orgmode.org/elpa/")))
+  (setq use-package-verbose (not (bound-and-true-p byte-compile-current-file)))
+
 #+END_SRC
 ** Paradox
 #+BEGIN_SRC emacs-lisp
   (use-package paradox
     :ensure paradox
     :commands (paradox-upgrade-packages paradox-list-packages)
-    :config (setq paradox-execute-asynchronously t)
+    :config
+    (setq paradox-execute-asynchronously t)
+    (setq paradox-github-token t) ; I don't want to be prompted about this integration
     )
 #+END_SRC
-* Add library paths
-
-#+BEGIN_SRC emacs-lisp
-  (add-to-list 'load-path '"~/lib/emacs_el/")
-  (add-to-list 'load-path '"~/lib/emacs_el/magit-annex")
-#+END_SRC
 * Disable custom-vars
 #+BEGIN_SRC emacs-lisp
   ;; Set the custom file to /dev/null and don't bother to load it
@@ -161,6 +141,36 @@ load  [[https://github.com/jwiegley/use-package/][use-package]] even faster
     )
 
 #+END_SRC
+
+** Flycheck
+#+begin_src emacs-lisp :tangle yes
+(use-package flycheck
+  :ensure t
+  :diminish ðŸ¦‹
+  :if (version<= "24.4" emacs-version)
+  :commands flycheck-mode
+  :hook ((prog-mode . flycheck-mode)
+         )
+)
+;; Other pkgs
+(use-package flycheck-tip
+  :ensure t
+  :commands 'flycheck-tip-cycle
+  :after flycheck
+  :bind (:map flycheck-mode-map
+              ("C-c C-n" . flycheck-tip-cycle)))
+
+(use-package flycheck-package
+  :ensure t)
+
+(use-package flycheck-checkpatch
+  :ensure t
+  :config (flycheck-checkpatch-setup)
+  :config (setq flycheck-checkers (delete 'checkpatch
+  flycheck-checkers))
+  :config (add-to-list 'flycheck-checkers 'checkpatch t))
+#+end_src  
+
 ** Flymake
 #+begin_src emacs-lisp :tangle yes
   (use-package flymake
@@ -673,10 +683,12 @@ value, scrolling continues until there is no more output.
 ** SQL mode
 #+BEGIN_SRC emacs-lisp
   ; load sql-indent when sql is loaded
+(use-package sql-indent
+  :hook sql-mode
+  )
 (use-package sql
   :mode (("\\.sql\\'" . sql-mode))
-  :config
-  (require sql-indent))
+  )
 #+END_SRC
 ** Ediff
 #+BEGIN_SRC emacs-lisp
@@ -980,7 +992,7 @@ This can be used to link things pretty quickly if necessary
     ("o" (find-file "~/projects/org-notes/ool.org"))
     ("f" (find-file "~/projects/org-notes/fh.org"))
     ("s" (find-file "~/projects/org-notes/sndservers.org"))
-    ("r" (find-file "~/projects/org-notes/refile.org"))
+    ("r" (find-file my/org-refile-file))
     ("p" (find-file "~/projects/research/papers_to_read.org"))
     ("R" (find-file "~/projects/research/paper_notes.org"))
     ("h" (find-file "~/projects/org-notes/hpcbio.org"))
@@ -1203,8 +1215,8 @@ This can be used to link things pretty quickly if necessary
     (defun dla/ess-region-remote-eval (start end)
       "Evaluate region in a remote ESS instance"
       (interactive "r")
-      (shell-command-on-region start end "eval_r" (get-buffer-create "***essregionremoteeval***"))
-      kill-buffer "***essregionremoteeval***")
+      (shell-command-on-region start end "eval_r" (get-buffer-create "***essregionremoteeval***") nil nil nil)
+      (kill-buffer "***essregionremoteeval***"))
     ;; Don't restore history or save workspace image
     '(inferior-R-args "--no-restore-history --no-save")
     )
@@ -1221,6 +1233,14 @@ From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colori
   )
 #+END_SRC
 
+** YAML Mode
+#+BEGIN_SRC emacs-lisp
+  (use-package yaml-mode
+    ;; add ess to the x major mode
+    :mode ("\\.\\(yaml|yml\\)\\'" . yaml-mode)
+  )
+#+END_SRC
+
 ** Polymode
 #+BEGIN_SRC emacs-lisp
 (use-package poly-noweb
@@ -1288,10 +1308,27 @@ From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colori
     (setq atomic-chrome-buffer-open-style 'full)
     )
 #+END_SRC
+** Edit Server
+#+BEGIN_SRC emacs-lisp
+  (use-package edit-server
+    :ensure t
+    :commands edit-server-start
+    :init (if after-init-time
+              (edit-server-start)
+            (add-hook 'after-init-hook
+                      #'(lambda() (edit-server-start))))
+    :config (setq edit-server-new-frame-alist
+                  '((name . "Edit with Emacs FRAME")
+                    (top . 200)
+                    (left . 200)
+                    (width . 80)
+                    (height . 25)
+                    (minibuffer . t)
+                    (menu-bar-lines . t)
+                    (window-system . x)))
+    )
+#+END_SRC
 ** Multiple Cursors
-   :PROPERTIES:
-   :ID:       6fcf218b-a762-4c37-9339-a8202ddeb544
-   :END:
 [[https://github.com/magnars/multiple-cursors.el][Multiple Cursors]]
 #+BEGIN_SRC emacs-lisp
   (use-package multiple-cursors
@@ -1356,6 +1393,71 @@ From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colori
     (setq default-abbrev-mode t))
 #+END_SRC
 
+** Debugging (realgud)
+#+BEGIN_SRC emacs-lisp
+(use-package realgud
+  :ensure t
+  )
+#+END_SRC
+** Python Programming
+#+BEGIN_SRC emacs-lisp
+(use-package python-mode
+  :hook
+  (python-mode . pyenv-mode)
+  (python-mode . flycheck-mode)
+  (python-mode . company-mode)
+  (python-mode . blacken-mode)
+  (python-mode . yas-minor-mode)
+  (python-mode . anaconda-mode)
+  )
+(use-package pyenv
+  :ensure t
+  )
+(use-package blacken
+  :init
+  (setq-default blacken-fast-unsafe t)
+  (setq-default blacken-line-length 80)
+  :ensure t)
+(use-package anaconda-mode
+  :ensure t
+  )
+
+(use-package elpy
+  :ensure t
+  :init
+  (elpy-enable)
+  )
+#+END_SRC
+# *** Jedi
+# #+BEGIN_SRC emacs-lisp
+#   (use-package company-jedi
+#     :ensure t
+#     :hook (python-mode . (add-to-list 'company-backends 'company-jedi))
+#     :hook (python-mode  . 'jedi:setup)
+#     :config
+#     (setq jedi:complete-on-dot t)
+#     )
+# #+END_SRC
+*** Black
+#+begin_src emacs-lisp :tangle yes
+  (use-package python-black
+    :demand t
+    :after python)
+#+end_src
+*** Sphinx Documentation
+#+begin_src emacs-lisp :tangle yes
+  (use-package numpydoc
+    :ensure t
+    :after python
+    :bind (:map python-mode-map
+                ("C-c C-n" . numpydoc-generate)))
+  (use-package sphinx-doc
+    :ensure t
+    :config
+    (sphinx-doc-mode t)
+    (setq sphinx-doc-include-types t)
+    :after python)
+#+end_src
 ** Go language
 #+BEGIN_SRC emacs-lisp
 (use-package go-mode
@@ -1572,24 +1674,19 @@ From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colori
 
   ; org mode agenda files
   (setq org-agenda-files
-        (quote ("~/projects/org-notes/debbugs.org"
-            "~/projects/org-notes/notes.org"
-            "~/projects/org-notes/holidays.org"
-            "~/projects/org-notes/refile.org"
-            "~/projects/org-notes/diary.org"
-            "~/projects/org-notes/ool.org"
-            "~/projects/org-notes/sndservers.org"
-            "~/projects/org-notes/chaim.org"
-            "~/projects/org-notes/wildman.org"
-            "~/projects/org-notes/uddin.org"
-            "~/projects/org-notes/reviews.org"
-            "~/projects/org-notes/laurel.org"
-            "~/projects/org-notes/from-calendar.org"
-            "~/org-mode/from-mobile.org"
-            "~/projects/org-notes/fh.org")))
+        (append
+        (file-expand-wildcards "~/projects/org-notes/*.org")
+        (file-expand-wildcards "~/org-mode/from-mobile.org")
+        (file-expand-wildcards "~/org-notes-*/*.org")
+        )
+  )
+  (setq my/org-refile-file
+        (car (seq-filter
+              (lambda (file) (string-match-p (regexp-quote "/refile.org") file))
+              org-agenda-files)))
 
   (set-register ?n (cons 'file "~/projects/org-notes/notes.org"))
-  (set-register ?r (cons 'file "~/projects/org-notes/refile.org"))
+  (set-register ?r (cons 'file my/org-refile-file))
   (set-register ?o (cons 'file "~/projects/org-notes/ool.org"))
   (set-register ?s (cons 'file "~/projects/org-notes/sndservers.org"))
   (set-register ?c (cons 'file "~/projects/org-notes/chaim.org"))
@@ -1621,33 +1718,33 @@ From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colori
 ** Capture Templates
 #+BEGIN_SRC emacs-lisp
   (setq org-capture-templates  ;; mail-specific note template, identified by "m"
-        `(("m" "Mail" entry (file "~/projects/org-notes/refile.org")
+        `(("m" "Mail" entry (file my/org-refile-file)
            "* %?\n\n  Source: %u, [[%:link][%:description]]\n  %:initial")
-          ("t" "todo" entry (file "~/projects/org-notes/refile.org")
+          ("t" "todo" entry (file my/org-refile-file)
            "* TODO %?\n  :PROPERTIES:\n  :END:\n  :LOGBOOK:\n  :END:\n%U\n%a\n" :clock-in t :clock-resume t)
-          ("r" "respond" entry (file "~/projects/org-notes/refile.org")
+          ("r" "respond" entry (file my/org-refile-file)
            "* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
-          ("n" "note" entry (file "~/projects/org-notes/refile.org")
+          ("n" "note" entry (file my/org-refile-file)
            "* %? :NOTE:\n%U\n%a\n" :clock-in t :clock-resume t)
-          ("s" "schedule" entry (file "~/projects/org-notes/refile.org")
+          ("s" "schedule" entry (file my/org-refile-file)
            "* %? :cal:\n%^{scheduled:}t\n%U\n%a\n" :clock-in t :clock-resume t)
           ("j" "Journal" entry (file+datetree "~/projects/org-notes/diary.org")
            "* %?\n%U\n" :clock-in t :clock-resume t)
-          ("w" "org-protocol" entry (file "~/projects/org-notes/refile.org")
+          ("w" "org-protocol" entry (file my/org-refile-file)
            "* TODO Review %c\n%U\n" :immediate-finish t)
-          ("M" "Meeting" entry (file "~/projects/org-notes/refile.org")
+          ("M" "Meeting" entry (file my/org-refile-file)
            "* MEETING with %? :MEETING:\n%U" :clock-in t :clock-resume t)
-          ("S" "Seminar" entry (file "~/projects/org-notes/refile.org")
+          ("S" "Seminar" entry (file my/org-refile-file)
            "* SEMINAR notes %? :SEMINAR:\n%U" :clock-in t :clock-resume t)
           ("P" "Paper to read" entry (file+headline "~/projects/research/papers_to_read.org" "Refile")
            "* TODO Get/Read %? \n%U" :clock-in t :clock-resume t)
-          ("p" "Phone call" entry (file "~/projects/org-notes/refile.org")
+          ("p" "Phone call" entry (file my/org-refile-file)
            "* PHONE %? :PHONE:\n%U" :clock-in t :clock-resume t)
            ("J" "job" entry (file+olp "~/projects/org-notes/notes.org"
                                        "Jobs"
                                        ,(format-time-string "Positions %Y"))
            "* TODO Apply for %? :job:\nSCHEDULED: <%<%Y-%m-%d>>\n%U\n%x\n" :clock-in t :clock-resume t)
-          ("h" "Habit" entry (file "~/projects/org-notes/refile.org")
+          ("h" "Habit" entry (file my/org-refile-file)
            "* NEXT %?\n%U\n%a\nSCHEDULED: %(format-time-string \"<%Y-%m-%d .+1d/3d>\")\n:PROPERTIES:\n:STYLE: habit\n:REPEAT_TO_STATE: NEXT\n:END:\n%a\n")
           )
         )
@@ -1717,7 +1814,7 @@ From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colori
     (interactive)
     (save-excursion
       (org-back-to-heading 'invisible-ok)
-      (hide-other)
+      (outline-hide-other)
       (org-cycle)
       (org-cycle)
       (org-cycle)))
@@ -1738,22 +1835,27 @@ From http://julien.danjou.info/projects/emacs-packages#rainbow-mode, this colori
   (setq org-use-fast-todo-selection t)
   (setq org-treat-S-cursor-todo-selection-as-state-change nil)
 
-  ; create function to create headlines in file. This comes from
-  ; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
-  (defun my/org-add-ids-to-headlines-in-file ()
-    "Add ID properties to all headlines in the current file which
-  do not already have one."
-    (interactive)
-    (org-map-entries 'org-id-get-create))
-  (defun dla/org-update-ids-to-headlines-in-file ()
-    "Add or replace ID properties to all headlines in the current file 
-  (or narrowed region)."
-    (interactive)
-    (org-map-entries '(lambda () (org-id-get-create t))))
-  ; if we wanted to do this to every buffer, do the following:
-  ; (add-hook 'org-mode-hook
-  ;           (lambda ()
-  ;             (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
+; create function to create headlines in file. This comes from
+; http://stackoverflow.com/questions/13340616/assign-ids-to-every-entry-in-org-mode
+(defun my/org-add-ids-to-headlines-in-file ()
+  "Add ID properties to all headlines in the current file which
+do not already have one."
+  (interactive)
+  (save-excursion
+    (widen)
+    (goto-char (point-min))
+    (when (not (re-search-forward "^#\\+OPTIONS:.*auto-id:f" (point-max) t))
+      (org-map-entries 'org-id-get-create))))
+(defun dla/org-update-ids-to-headlines-in-file ()
+  "Add or replace ID properties to all headlines in the current file 
+(or narrowed region)."
+  (interactive)
+
+  (org-map-entries '(lambda () (org-id-get-create t))))
+; if we wanted to do this to every buffer, do the following:
+(add-hook 'org-mode-hook
+          (lambda ()
+            (add-hook 'before-save-hook 'my/org-add-ids-to-headlines-in-file nil 'local)))
 #+END_SRC
 ** Org ID locations
 #+BEGIN_SRC emacs-lisp
@@ -2005,9 +2107,6 @@ Maildir, or by Message-ID."
 
 #+END_SRC
 ** LaTeX configuration
-   :PROPERTIES:
-   :ID:       7135ba17-6a50-4eed-84ca-b90afa5b12f8
-   :END:
 #+BEGIN_SRC emacs-lisp
 (use-package ox-extra
   :config
@@ -2230,7 +2329,7 @@ as the default task."
   ;; We're in the agenda
   ;;
   (let* ((marker (org-get-at-bol 'org-hd-marker))
-         (tags (org-with-point-at marker (org-get-tags-at))))
+         (tags (org-with-point-at marker (org-get-tags))))
     (if (and (eq arg 4) tags)
         (org-agenda-clock-in '(16))
       (bh/clock-in-organization-task-as-default)))
@@ -2466,6 +2565,11 @@ same directory as the org-buffer and insert a link to this file."
   )
 #+END_SRC
 * Keybindings
+** Home/End Begining/End of line
+#+BEGIN_SRC emacs-lisp
+  (global-set-key [home] 'move-beginning-of-line)
+  (global-set-key [end] 'move-end-of-line)
+#+END_SRC
 ** Goto line
 #+BEGIN_SRC emacs-lisp
   (global-unset-key "\M-g")
@@ -2521,16 +2625,28 @@ same directory as the org-buffer and insert a link to this file."
   (show-paren-mode 1)
   (setq show-paren-delay 0.2)
 
+#+END_SRC
+** My Username
+#+BEGIN_SRC emacs-lisp
   (setq user-mail-address "don@donarmstrong.com")
 
+#+END_SRC
+** Use primary selection on unix machines
+#+BEGIN_SRC emacs-lisp
   ;; switch back to the old primary selection method
-  (setq x-select-enable-clipboard nil)
-  (setq x-select-enable-primary t)
+  (if (or (string-equal system-type "darwin")
+          (string-equal system-type "windows")
+          )
+      (progn
+        (setq select-enable-clipboard t)
+        (setq select-enable-primary nil)
+        )
+    (progn
+      (setq select-enable-clipboard nil)
+      (setq select-enable-primary t)
+      ))
   ; (setq mouse-drag-copy-region t)
 
-  (fset 'perl-mode 'cperl-mode)
-  ;;(load-file "cperl-mode.el")
-
   ;; tramp configuration
   (setq tramp-use-ssh-controlmaster-options nil)