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 marmalade)
(source org)
(source "marmalade" "https://marmalade-repo.org/packages/")
(source gnu)
;; Core --- core/core.el

View file

@ -30,6 +30,10 @@
'((tab-mark ?\t [?> ?\t])
(newline-mark 10 [36 10])))
(require 'saveplace)
(setq save-place-file (concat narf-temp-dir "saveplace")
save-place t)
;; Automatic minor modes ;;;;;;;;;;;
@ -58,19 +62,6 @@ enable multiple minor modes for the same regexp.")
(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 ;;;;;;;;;;;;;;;;;;;
(associate! sh-mode :match "/\\.?z\\(profile\\|login\\|logout\\|shrc\\|shenv\\)?$")
@ -105,7 +96,7 @@ details on NORECORD.")
;; If file is oversized...
(add-hook! find-file
(when (> (buffer-size) (* 1024 1024))
(when (> (buffer-size) 1048576)
(setq buffer-read-only t)
(buffer-disable-undo)
(fundamental-mode)
@ -114,25 +105,24 @@ details on NORECORD.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (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-font-lock-mode t) ; Enable syntax highlighting for older emacs
(electric-indent-mode -1) ; on by default
;; window config undo/redo
(setq winner-dont-bind-my-keys t)
(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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-package undo-tree
:defer t
:diminish undo-tree-mode
:config
(defalias 'redo #'undo-tree-redo)
(defalias 'undo #'undo-tree-undo)
;; Shut up undo-tree's constant complaining: http://youtu.be/Z6woIRLnbmE
(defadvice undo-tree-load-history-hook
(around undo-tree-load-history-shut-up activate)
(shut-up! ad-do-it))
@ -158,9 +148,6 @@ details on NORECORD.")
(use-package expand-region
: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
:commands goto-last-change)
@ -223,9 +210,5 @@ details on NORECORD.")
:commands (describe-buffer describe-command describe-file
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)
;;; 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-outer-text-objects-map "J" 'evil-indent-plus-a-indent-up-down))
(use-package evil-jumper
:init
(setq evil-jumper-auto-center nil
evil-jumper-auto-save-interval 3600)
:config (global-evil-jumper-mode +1))
;; (use-package evil-jumper
;; :init
;; (setq evil-jumper-auto-center nil
;; evil-jumper-auto-save-interval 3600)
;; :config (global-evil-jumper-mode +1))
(use-package evil-matchit
:commands (evilmi-jump-items evilmi-text-object global-evil-matchit-mode)

View file

@ -8,6 +8,7 @@
;; narf:... An ex command
;; narf|... A hook
;; narf*... An advising function
;; narf.... Custom hooks
;; ...! Macro
;;
;;;
@ -128,6 +129,17 @@
async-wait
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 ()
@ -153,7 +165,7 @@
(unless (server-running-p)
(server-start))
(add-hook! after-init (setq gc-cons-threshold 800000)))
(add-hook! after-init (setq gc-cons-threshold 850000)))
(provide 'core)
;;; core.el ends here

View file

@ -6,28 +6,6 @@
(when (narf/project-p)
(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)
(evil-define-command narf:helm-recentf (&optional bang)
"Ex-mode interface for `helm-recentf' and `helm-projectile-recentf'. If

View file

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