Config-wide code clean up

This commit is contained in:
Henrik Lissner 2015-11-27 03:40:10 -05:00
parent e85615e7fd
commit 436ca26a4e
7 changed files with 42 additions and 61 deletions

7
Cask
View file

@ -1,6 +1,11 @@
; (source "melpa", "https://melpa.org/packages/")
; (source "marmalade" "https://marmalade-repo.org/packages/")
; (source "org", "http://orgmode.org/elpa/")
; (source "gnu", "https://elpa.gnu.org")
(source melpa) (source melpa)
(source marmalade)
(source org) (source org)
(source "marmalade" "https://marmalade-repo.org/packages/")
(source gnu) (source gnu)
;; Core --- core/core.el ;; Core --- core/core.el

View file

@ -30,6 +30,10 @@
'((tab-mark ?\t [?> ?\t]) '((tab-mark ?\t [?> ?\t])
(newline-mark 10 [36 10]))) (newline-mark 10 [36 10])))
(require 'saveplace)
(setq save-place-file (concat narf-temp-dir "saveplace")
save-place t)
;; Automatic minor modes ;;;;;;;;;;; ;; Automatic minor modes ;;;;;;;;;;;
@ -58,19 +62,6 @@ enable multiple minor modes for the same regexp.")
(add-hook! find-file 'narf|enable-minor-mode-maybe) (add-hook! find-file 'narf|enable-minor-mode-maybe)
;; Hook for window switching ;;;;;;;
(defvar narf.window-switch-hook '()
"Hooks run before switching windows. Hooks take two arguments (one is
optional): WINDOW and NORECORD. WINDOW is the window being switched to. Use
`current-buffer' to get the buffer being switched from. See `select-window' for
details on NORECORD.")
(defun narf*run-window-switch-hooks (window &optional norecord)
(run-hook-with-args 'narf.window-switch-hook window norecord))
(advice-add 'select-window :before 'narf*run-window-switch-hooks)
;; Modes 'n hooks ;;;;;;;;;;;;;;;;;;; ;; Modes 'n hooks ;;;;;;;;;;;;;;;;;;;
(associate! sh-mode :match "/\\.?z\\(profile\\|login\\|logout\\|shrc\\|shenv\\)?$") (associate! sh-mode :match "/\\.?z\\(profile\\|login\\|logout\\|shrc\\|shenv\\)?$")
@ -105,7 +96,7 @@ details on NORECORD.")
;; If file is oversized... ;; If file is oversized...
(add-hook! find-file (add-hook! find-file
(when (> (buffer-size) (* 1024 1024)) (when (> (buffer-size) 1048576)
(setq buffer-read-only t) (setq buffer-read-only t)
(buffer-disable-undo) (buffer-disable-undo)
(fundamental-mode) (fundamental-mode)
@ -114,25 +105,24 @@ details on NORECORD.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (global-whitespace-mode 1) ; Show whitespace ;; (global-whitespace-mode 1) ; Show whitespace
;; (global-font-lock-mode t) ; Enable syntax highlighting for older emacs
(global-auto-revert-mode 1) ; revert buffers for changed files (global-auto-revert-mode 1) ; revert buffers for changed files
(global-font-lock-mode t) ; Enable syntax highlighting for older emacs
(electric-indent-mode -1) ; on by default (electric-indent-mode -1) ; on by default
;; window config undo/redo ;; window config undo/redo
(setq winner-dont-bind-my-keys t) (setq winner-dont-bind-my-keys t)
(winner-mode 1) (winner-mode 1)
(add-hook! after-init (setq winner-boring-buffers narf-ignore-buffers)) (add-hook! after-init
(setq winner-boring-buffers narf-ignore-buffers))
;; Plugins ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Plugins ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package undo-tree (use-package undo-tree
:defer t
:diminish undo-tree-mode :diminish undo-tree-mode
:config :config
(defalias 'redo #'undo-tree-redo) (defalias 'redo #'undo-tree-redo)
(defalias 'undo #'undo-tree-undo) (defalias 'undo #'undo-tree-undo)
;; Shut up undo-tree's constant complaining: http://youtu.be/Z6woIRLnbmE
(defadvice undo-tree-load-history-hook (defadvice undo-tree-load-history-hook
(around undo-tree-load-history-shut-up activate) (around undo-tree-load-history-shut-up activate)
(shut-up! ad-do-it)) (shut-up! ad-do-it))
@ -158,9 +148,6 @@ details on NORECORD.")
(use-package expand-region (use-package expand-region
:commands (er/expand-region er/contract-region er/mark-symbol er/mark-word)) :commands (er/expand-region er/contract-region er/mark-symbol er/mark-word))
(use-package fancy-narrow
:commands (fancy-narrow-to-region fancy-widen))
(use-package goto-last-change (use-package goto-last-change
:commands goto-last-change) :commands goto-last-change)
@ -223,9 +210,5 @@ details on NORECORD.")
:commands (describe-buffer describe-command describe-file :commands (describe-buffer describe-command describe-file
describe-keymap describe-option describe-option-of-type)) describe-keymap describe-option describe-option-of-type))
(require 'saveplace)
(setq save-place-file (concat narf-temp-dir "saveplace"))
(save-place-mode +1)
(provide 'core-editor) (provide 'core-editor)
;;; core-editor.el ends here ;;; core-editor.el ends here

View file

@ -246,11 +246,11 @@
(define-key evil-inner-text-objects-map "J" 'evil-indent-plus-i-indent-up-down) (define-key evil-inner-text-objects-map "J" 'evil-indent-plus-i-indent-up-down)
(define-key evil-outer-text-objects-map "J" 'evil-indent-plus-a-indent-up-down)) (define-key evil-outer-text-objects-map "J" 'evil-indent-plus-a-indent-up-down))
(use-package evil-jumper ;; (use-package evil-jumper
:init ;; :init
(setq evil-jumper-auto-center nil ;; (setq evil-jumper-auto-center nil
evil-jumper-auto-save-interval 3600) ;; evil-jumper-auto-save-interval 3600)
:config (global-evil-jumper-mode +1)) ;; :config (global-evil-jumper-mode +1))
(use-package evil-matchit (use-package evil-matchit
:commands (evilmi-jump-items evilmi-text-object global-evil-matchit-mode) :commands (evilmi-jump-items evilmi-text-object global-evil-matchit-mode)

View file

@ -146,7 +146,7 @@
:preface :preface
(defvar narf--hl-nlinum-overlay nil) (defvar narf--hl-nlinum-overlay nil)
(defvar narf--hl-nlinum-line nil) (defvar narf--hl-nlinum-line nil)
(defvar nlinum-format " %4d ") (defvar nlinum-format " %4d ")
(defface linum-highlight-face '((t (:inherit linum))) "Face for line highlights") (defface linum-highlight-face '((t (:inherit linum))) "Face for line highlights")
(setq linum-format "%3d ") (setq linum-format "%3d ")
:init :init

View file

@ -8,6 +8,7 @@
;; narf:... An ex command ;; narf:... An ex command
;; narf|... A hook ;; narf|... A hook
;; narf*... An advising function ;; narf*... An advising function
;; narf.... Custom hooks
;; ...! Macro ;; ...! Macro
;; ;;
;;; ;;;
@ -128,6 +129,17 @@
async-wait async-wait
async-inject-variables)) async-inject-variables))
;; Custom Hooks ;;;;;;;;;;;;;;;;;;;;;;;;
(defvar narf.window-switch-hook '()
"Hooks run before switching windows. Hooks take two arguments (one is
optional): WINDOW and NORECORD. WINDOW is the window being switched to. Use
`current-buffer' to get the buffer being switched from. See `select-window' for
details on NORECORD.")
(defun narf*run-window-switch-hooks (window &optional norecord)
(run-hook-with-args 'narf.window-switch-hook window norecord))
(advice-add 'select-window :before 'narf*run-window-switch-hooks)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun narf-init () (defun narf-init ()
@ -153,7 +165,7 @@
(unless (server-running-p) (unless (server-running-p)
(server-start)) (server-start))
(add-hook! after-init (setq gc-cons-threshold 800000))) (add-hook! after-init (setq gc-cons-threshold 850000)))
(provide 'core) (provide 'core)
;;; core.el ends here ;;; core.el ends here

View file

@ -6,28 +6,6 @@
(when (narf/project-p) (when (narf/project-p)
(projectile-invalidate-cache nil))) (projectile-invalidate-cache nil)))
;;;###autoload
(defun narf/helm-get-org-candidates-in-file (filename min-depth max-depth &optional fontify nofname)
(with-current-buffer (pcase filename
((pred bufferp) filename)
((pred stringp) (find-file-noselect filename)))
(and fontify (jit-lock-fontify-now))
(let ((match-fn (if fontify 'match-string 'match-string-no-properties)))
(save-excursion
(goto-char (point-min))
(cl-loop with width = (window-width)
while (re-search-forward org-complex-heading-regexp nil t)
if (let ((num-stars (length (match-string-no-properties 1))))
(and (>= num-stars min-depth) (<= num-stars max-depth)))
collect `(,(let ((heading (funcall match-fn 4))
(file (unless nofname
(concat (f-no-ext (f-relative filename org-directory)) ":")))
(level (length (match-string-no-properties 1))))
(org-format-outline-path
(append (org-get-outline-path t level heading)
(list heading)) width file))
. ,(point-marker)))))))
;;;###autoload (autoload 'narf:helm-recentf "defuns-helm" nil t) ;;;###autoload (autoload 'narf:helm-recentf "defuns-helm" nil t)
(evil-define-command narf:helm-recentf (&optional bang) (evil-define-command narf:helm-recentf (&optional bang)
"Ex-mode interface for `helm-recentf' and `helm-projectile-recentf'. If "Ex-mode interface for `helm-recentf' and `helm-projectile-recentf'. If

View file

@ -185,9 +185,12 @@ will function properly."
(defun narf@org-latex () (defun narf@org-latex ()
(setq-default (setq-default
org-latex-preview-ltxpng-directory (concat narf-temp-dir "ltxpng/") org-latex-preview-ltxpng-directory (concat narf-temp-dir "ltxpng/")
org-latex-remove-logfiles t
org-latex-create-formula-image-program 'dvipng org-latex-create-formula-image-program 'dvipng
org-startup-with-latex-preview t org-startup-with-latex-preview t
org-highlight-latex-and-related '(latex)) org-highlight-latex-and-related '(latex)
org-latex-packages-alist
'(("" "gauss" t)))
(plist-put org-format-latex-options :scale 1.1)) (plist-put org-format-latex-options :scale 1.1))
@ -234,7 +237,7 @@ will function properly."
(defface org-headline-todo '((t ())) "Face for todo headlines") (defface org-headline-todo '((t ())) "Face for todo headlines")
(defface org-todo-high '((t ())) "Face for high-priority todo") (defface org-todo-high '((t ())) "Face for high-priority todo")
(defface org-todo-vhigh '((t ())) "Face for very high-priority todo") (defface org-todo-vhigh '((t ())) "Face for very high-priority todo")
(defface org-whitespace '((t ())) "Face for spaces") ;; (defface org-whitespace '((t ())) "Face for spaces")
(defface org-list-bullet '((t ())) "Face for list bullets") (defface org-list-bullet '((t ())) "Face for list bullets")
(defface org-todo-checkbox '((t ())) "Face for list bullets") (defface org-todo-checkbox '((t ())) "Face for list bullets")
(font-lock-add-keywords (font-lock-add-keywords
@ -242,9 +245,9 @@ will function properly."
(1 (narf/show-as ?#))) (1 (narf/show-as ?#)))
("^ *\\(#\\+end_src\\>\\)" ("^ *\\(#\\+end_src\\>\\)"
(1 (narf/show-as ?#))) (1 (narf/show-as ?#)))
("\\(#\\+begin_quote\\>\\)" ("^ *\\(#\\+begin_quote\\>\\)"
(1 (narf/show-as ?\"))) (1 (narf/show-as ?\")))
("\\(#\\+end_quote\\>\\)" ("^ *\\(#\\+end_quote\\>\\)"
(1 (narf/show-as ?\"))) (1 (narf/show-as ?\")))
;; Hide TODO tags ;; Hide TODO tags
@ -291,7 +294,7 @@ will function properly."
(evil-org-mode +1) (evil-org-mode +1)
(org-bullets-mode +1) (org-bullets-mode +1)
(org-indent-mode +1) (org-indent-mode +1)
(text-scale-set 1) ;; (text-scale-set 1)
(diminish 'org-indent-mode) (diminish 'org-indent-mode)
@ -456,7 +459,7 @@ will function properly."
:n ",d" 'org-time-stamp :n ",d" 'org-time-stamp
:n ",r" 'org-refile :n ",r" 'org-refile
:n ",s" 'org-schedule :n ",s" 'org-schedule
:n ",oa" 'narf/org-reveal-attachments :n ",oa" 'narf/org-attachment-reveal
:n ", SPC" 'narf/org-toggle-checkbox :n ", SPC" 'narf/org-toggle-checkbox
:n ", RET" 'org-archive-subtree :n ", RET" 'org-archive-subtree