NARF v0.7.0
vcs: + +git-gutter to conf-modes; -git-gutter from evil-insert-state-exit + switch github-browse-file for browse-at-remote + fix <leader>ob; add <leader>d[./sr] vc bindings + vc-annotate bindings and initial state Workgroups2 integration: + don't mess with buffers (speeds up emacs a lot!) + unicode numbers in display + single display function + remember workgroup uid instead (and smarter :tabrename) + clean up after wg update Org-mode + give highlight precedence to links in org-mode + enable encryption + config clean up + use different font for org + exclude attachments in recentf + redo latex and inline-image config + add narf/org-open-notes + update file templates for org CRM Mode-line + polish mode-line + decouple from spaceline-segments.el + refactor narf|spaceline-env-update + add macro-recording and buffer-size indicators to mode-line + python: '2>&1' in env-command + flycheck fringe indicator: change to arrow Aesthetics + update narf-dark-theme + add narf-minibuffer-active face + change writing indicator in writing-mode Misc + fix whitespace in display-startup-echo-area-message + reset fonts for more unicode characters + custom imenu entries + helm-imenu fontification + enable yascroll-bar in REPLs + reorganize my-commands.el + force quit iedit on ESC in normal mode + update snippets submodule + remove ido init (helm handles it all) [EXPERIMENTAL] + back to Terminus(TTF) font + popwin: update config for git-gutter and vc-diff windows + highlight :g[lobal] and :al[ign] matches + decouple narf/get-buffers+narf/get-all-buffers from wg-mess-with-buffer-list + fix narf/helm-buffers-dwim (add interactive form)
This commit is contained in:
parent
8943bbc79f
commit
aa26332d00
29 changed files with 691 additions and 421 deletions
|
@ -75,6 +75,17 @@
|
|||
(defmacro $expand (path)
|
||||
`(evil-ex-replace-special-filenames ,path))
|
||||
|
||||
;; buffer-local ex commands, thanks to:
|
||||
;; http://emacs.stackexchange.com/questions/13186
|
||||
(defun evil-ex-define-cmd-local (cmd function)
|
||||
"Locally binds the function FUNCTION to the command CMD."
|
||||
(unless (local-variable-p 'evil-ex-commands)
|
||||
(setq-local evil-ex-commands (copy-alist evil-ex-commands)))
|
||||
(evil-ex-define-cmd cmd function))
|
||||
;; Shortcuts for `evil-ex-define-cmd'
|
||||
(defalias 'exmap 'evil-ex-define-cmd)
|
||||
(defalias 'exmap! 'evil-ex-define-cmd-local)
|
||||
|
||||
(progn ; evil hacks
|
||||
(defadvice evil-force-normal-state (after evil-esc-quit activate)
|
||||
"Close popups, disable search highlights and quit the minibuffer if open."
|
||||
|
@ -92,14 +103,6 @@
|
|||
(mapcar (lambda (i) (if (numberp i) (truncate i) i)) args))
|
||||
(advice-add 'evil-move-to-column :filter-args 'narf*evil-move-to-column-fix)
|
||||
|
||||
;; buffer-local ex commands, thanks to:
|
||||
;; http://emacs.stackexchange.com/questions/13186
|
||||
(defun evil-ex-define-cmd-local (cmd function)
|
||||
"Locally binds the function FUNCTION to the command CMD."
|
||||
(unless (local-variable-p 'evil-ex-commands)
|
||||
(setq-local evil-ex-commands (copy-alist evil-ex-commands)))
|
||||
(evil-ex-define-cmd cmd function))
|
||||
|
||||
;; Hide keystroke display while isearch is active
|
||||
(add-hook! isearch-mode (setq echo-keystrokes 0))
|
||||
(add-hook! isearch-mode-end (setq echo-keystrokes 0.02))
|
||||
|
@ -188,35 +191,45 @@
|
|||
"\\1" file-name t)))
|
||||
file-name))
|
||||
|
||||
;; Highlight buffer match interactive codes
|
||||
(defvar narf-buffer-match-global evil-ex-substitute-global
|
||||
"Whether or not buffer-match ex completion should add the ?g flag to searches.")
|
||||
(evil-ex-define-argument-type buffer-match
|
||||
:runner
|
||||
(lambda (flag &optional arg)
|
||||
(let ((hl-name 'evil-ex-buffer-match))
|
||||
(with-selected-window (minibuffer-selected-window)
|
||||
(narf/-ex-match-init hl-name)
|
||||
(narf/-ex-buffer-match arg hl-name (list (if narf-buffer-match-global ?g)))))))
|
||||
;; Make :g[lobal] highlight matches
|
||||
(defvar narf-buffer-match-global evil-ex-substitute-global "")
|
||||
(defun narf--ex-buffer-match (flag &optional arg)
|
||||
(let ((hl-name 'evil-ex-buffer-match))
|
||||
(with-selected-window (minibuffer-selected-window)
|
||||
(narf/-ex-match-init hl-name)
|
||||
(narf/-ex-buffer-match arg hl-name (list (if narf-buffer-match-global ?g))))))
|
||||
(defun narf--ex-global-match (flag &optional arg)
|
||||
(let ((hl-name 'evil-ex-global-match))
|
||||
(with-selected-window (minibuffer-selected-window)
|
||||
(narf/-ex-match-init hl-name)
|
||||
(let ((result (car-safe (evil-ex-parse-global arg))))
|
||||
(narf/-ex-buffer-match result hl-name nil (point-min) (point-max))))))
|
||||
|
||||
(evil-ex-define-argument-type buffer-match :runner narf--ex-buffer-match)
|
||||
(evil-ex-define-argument-type global-match :runner narf--ex-global-match)
|
||||
|
||||
(evil-define-interactive-code "<//>"
|
||||
"Ex buffer match argument."
|
||||
:ex-arg buffer-match
|
||||
(list (when (evil-ex-p) evil-ex-argument)))
|
||||
|
||||
;; Make :g[lobal] highlight matches
|
||||
(evil-ex-define-argument-type global-match
|
||||
:runner
|
||||
(lambda (flag &optional arg)
|
||||
(let ((hl-name 'evil-ex-global-match))
|
||||
(with-selected-window (minibuffer-selected-window)
|
||||
(narf/-ex-match-init hl-name)
|
||||
(let ((result (car-safe (evil-ex-parse-global arg))))
|
||||
(narf/-ex-buffer-match result hl-name nil (point-min) (point-max)))))))
|
||||
(evil-define-interactive-code "<g/>"
|
||||
"Ex global argument."
|
||||
(evil-define-interactive-code "<g//>"
|
||||
:ex-arg global-match
|
||||
(when (evil-ex-p)
|
||||
(evil-ex-parse-global evil-ex-argument))))
|
||||
(when (evil-ex-p) (evil-ex-parse-global evil-ex-argument)))
|
||||
|
||||
(evil-define-operator narf:align (&optional beg end bang pattern)
|
||||
(interactive "<r><!><//>")
|
||||
(align-regexp
|
||||
beg end
|
||||
(concat "\\(\\s-*\\)"
|
||||
(if bang
|
||||
(regexp-quote pattern)
|
||||
(rxt-pcre-to-elisp pattern)))
|
||||
1 1))
|
||||
(evil-define-operator narf:evil-ex-global (beg end pattern command &optional invert)
|
||||
:motion mark-whole-buffer
|
||||
:move-point nil
|
||||
(interactive "<r><g//><!>")
|
||||
(evil-ex-global beg end pattern command invert))
|
||||
(exmap "g[lobal]" 'narf:evil-ex-global))
|
||||
|
||||
;; evil plugins
|
||||
(use-package evil-anzu
|
||||
|
@ -246,6 +259,7 @@
|
|||
:functions (iedit-current-occurrence-string iedit-restrict-region)
|
||||
:commands (evil-iedit-state evil-iedit-state/iedit-mode)
|
||||
:config
|
||||
(advice-add 'evil-force-normal-state :after 'evil-iedit-state/quit-iedit-mode)
|
||||
(define-key evil-iedit-state-map (kbd "<escape>") 'evil-iedit-state/quit-iedit-mode)
|
||||
(define-key evil-visual-state-map (kbd "SPC") 'narf:iedit-restrict-to-region)
|
||||
(let ((map evil-iedit-state-map))
|
||||
|
|
|
@ -22,7 +22,27 @@
|
|||
;; Check buffer when normal mode is entered
|
||||
(add-hook! evil-normal-state-entry 'narf*flycheck-buffer)
|
||||
;; And on ESC in normal mode.
|
||||
(advice-add 'evil-force-normal-state :after 'narf*flycheck-buffer))
|
||||
(advice-add 'evil-force-normal-state :after 'narf*flycheck-buffer)
|
||||
|
||||
(define-fringe-bitmap 'flycheck-fringe-bitmap-double-arrow
|
||||
[0 0 0 0 8 24 56 120 56 24 8 0 0 0 0]
|
||||
;; (fringe-helper-convert
|
||||
;; "........"
|
||||
;; "........"
|
||||
;; "........"
|
||||
;; "........"
|
||||
;; "....X..."
|
||||
;; "...XX..."
|
||||
;; "..XXX..."
|
||||
;; ".XXXX..."
|
||||
;; "..XXX..."
|
||||
;; "...XX..."
|
||||
;; "....X..."
|
||||
;; "........"
|
||||
;; "........"
|
||||
;; "........"
|
||||
;; "........")
|
||||
))
|
||||
|
||||
(use-package flyspell :commands flyspell-mode)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
(use-package helm
|
||||
:init
|
||||
(defvar helm-global-prompt "> ")
|
||||
(defvar helm-global-prompt ">>> ")
|
||||
(setq-default
|
||||
helm-quick-update t
|
||||
helm-reuse-last-window-split-state t
|
||||
|
|
|
@ -6,18 +6,20 @@
|
|||
(setq popwin:popup-window-height 0.3)
|
||||
(mapc (lambda (rule) (push rule popwin:special-display-config))
|
||||
'(("*Help*" :position bottom :height 0.25 :stick t)
|
||||
(debugger-mode :position bottom :height 15)
|
||||
(debugger-mode :position bottom :height 15 :dedicated t :stick t)
|
||||
("*evil-registers*" :position bottom :height 0.3 :stick t)
|
||||
("*scratch*" :position bottom :height 20 :stick t)
|
||||
("*Apropos*" :position bottom :height 40 :stick t)
|
||||
("*Backtrace*" :position bottom :height 15 :stick t)
|
||||
("*Backtrace*" :position bottom :height 15 :dedicated t :stick t)
|
||||
("*Flycheck errors*" :position bottom :height 15 :stick t)
|
||||
("*quickrun*" :position bottom :height 15 :stick t)
|
||||
("*minor-modes*" :position bottom :height 0.5 :stick t)
|
||||
("^\\*CPU-Profiler-Report .+\\*$" :regexp t :position bottom :height 0.35)
|
||||
|
||||
;; vcs
|
||||
("\\*git-gutter.+\\*" :regexp t :position bottom :height 30 :stick t)
|
||||
("^\\*git-gutter.+\\*$" :regexp t :position bottom :height 0.4 :stick t)
|
||||
("*vc-diff*" :position bottom :height 0.4 :stick t)
|
||||
("*vc-change-log*" :position bottom :stick t :noselect t)
|
||||
|
||||
;; Helm
|
||||
("^\\*[Hh]elm.*?\\*\\'" :regexp t :position bottom :height 0.2)
|
||||
|
|
|
@ -22,12 +22,6 @@
|
|||
(add-to-list 'ido-ignore-files "\\`.DS_Store$")
|
||||
(add-to-list 'ido-ignore-files "Icon\\?$")
|
||||
|
||||
(ido-mode 1)
|
||||
(ido-everywhere 1)
|
||||
|
||||
(require 'ido-ubiquitous)
|
||||
(ido-ubiquitous-mode 1)
|
||||
|
||||
(add-hook! ido-setup
|
||||
(require 'ido-vertical-mode)
|
||||
(ido-vertical-mode 1)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
(setq rtog/goto-buffer-fun 'popwin:pop-to-buffer
|
||||
rtog/mode-repl-alist '())
|
||||
|
||||
(add-hook! repl-toggle-mode 'yascroll-bar-mode)
|
||||
(add-hook! repl-toggle-mode (evil-initialize-state 'emacs)))
|
||||
|
||||
(provide 'core-quickrun)
|
||||
|
|
386
core/core-ui.el
386
core/core-ui.el
|
@ -23,15 +23,18 @@
|
|||
|
||||
jit-lock-defer-time nil
|
||||
jit-lock-stealth-time 1
|
||||
idle-update-delay 1
|
||||
|
||||
split-width-threshold nil
|
||||
split-height-threshold 30
|
||||
split-width-threshold nil ; favor horizontal splits
|
||||
|
||||
;; Minibuffer resizing
|
||||
resize-mini-windows 'grow-only
|
||||
max-mini-window-height 0.3
|
||||
|
||||
fringe-indicator-alist (delq (assoc 'continuation fringe-indicator-alist)
|
||||
fringe-indicator-alist))
|
||||
|
||||
(defface narf-minibuffer-active '((t (:inherit mode-line))) "Face for active minibuffer")
|
||||
(defvar narf-fringe-size 6)
|
||||
(if window-system
|
||||
(progn
|
||||
|
@ -49,12 +52,15 @@
|
|||
(defun narf|minibuffer-setup ()
|
||||
(set-window-fringes (selected-window) 0 0 nil)
|
||||
(make-local-variable 'face-remapping-alist)
|
||||
(add-to-list 'face-remapping-alist '(default mode-line-inactive)))
|
||||
(add-to-list 'face-remapping-alist '(default narf-minibuffer-active)))
|
||||
(add-hook! minibuffer-setup 'narf|minibuffer-setup))
|
||||
(menu-bar-mode -1))
|
||||
|
||||
(mapc (lambda (x) (set-fontset-font "fontset-default" `(,x . ,x) "DejaVu Sans" nil 'prepend))
|
||||
'(?☑ ?☐))
|
||||
(mapc (lambda (x) (set-fontset-font "fontset-default" `(,x . ,x) (font-spec :name "DejaVu Sans") nil 'prepend))
|
||||
'(?☑ ?☐ ?✍ ?⚠))
|
||||
|
||||
(mapc (lambda (x) (set-fontset-font "fontset-default" `(,x . ,x) (font-spec :name "DejaVu Sans" :size 10) nil))
|
||||
'(?➊ ?➋ ?➌ ?➍ ?➎ ?❻ ?➐ ?➑ ?➒ ?➓))
|
||||
|
||||
(blink-cursor-mode 1) ; do blink cursor
|
||||
(tooltip-mode -1) ; show tooltips in echo area
|
||||
|
@ -218,7 +224,7 @@
|
|||
|
||||
;; Mode-line ;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(use-package spaceline-segments
|
||||
(use-package spaceline
|
||||
:init
|
||||
(defvar narf--env-version nil)
|
||||
(defvar narf--env-command nil)
|
||||
|
@ -227,173 +233,253 @@
|
|||
:config
|
||||
(setq-default
|
||||
powerline-default-separator nil
|
||||
powerline-height 19
|
||||
powerline-height 15
|
||||
spaceline-highlight-face-func 'spaceline-highlight-face-evil-state)
|
||||
|
||||
(defface mode-line-is-modified nil "Face for mode-line modified symbol")
|
||||
(defface mode-line-buffer-file nil "Face for mode-line buffer file path")
|
||||
|
||||
;; Custom modeline segments
|
||||
(spaceline-define-segment narf-buffer-path
|
||||
(if buffer-file-name
|
||||
(let* ((project-path (let (projectile-require-project-root) (projectile-project-root)))
|
||||
(buffer-path (file-relative-name buffer-file-name project-path))
|
||||
(max-length (/ (window-width) 2))
|
||||
(path-len (length buffer-path)))
|
||||
(concat (file-name-nondirectory (directory-file-name project-path))
|
||||
"/"
|
||||
(if (> path-len max-length)
|
||||
(concat "…" (replace-regexp-in-string
|
||||
"^.*?/" "/"
|
||||
(substring buffer-path (- path-len max-length) path-len)))
|
||||
buffer-path)))
|
||||
"%b")
|
||||
:face (if active 'mode-line-buffer-file 'mode-line-inactive)
|
||||
:skip-alternate t
|
||||
:tight-right t)
|
||||
(progn ;; Custom modeline segments
|
||||
(spaceline-define-segment *buffer-path
|
||||
(if buffer-file-name
|
||||
(let* ((project-path (let (projectile-require-project-root) (projectile-project-root)))
|
||||
(buffer-path (file-relative-name buffer-file-name project-path))
|
||||
(max-length (/ (window-width) 2))
|
||||
(path-len (length buffer-path)))
|
||||
(concat (file-name-nondirectory (directory-file-name project-path))
|
||||
"/"
|
||||
(if (> path-len max-length)
|
||||
(concat "…" (replace-regexp-in-string
|
||||
"^.*?/" "/"
|
||||
(substring buffer-path (- path-len max-length) path-len)))
|
||||
buffer-path)))
|
||||
"%b")
|
||||
:face (if active 'mode-line-buffer-file 'mode-line-inactive)
|
||||
:skip-alternate t
|
||||
:tight-right t)
|
||||
|
||||
(spaceline-define-segment narf-buffer-modified
|
||||
(concat
|
||||
(when buffer-file-name
|
||||
(concat
|
||||
(when (buffer-modified-p) "[+]")
|
||||
(unless (file-exists-p buffer-file-name) "[!]")))
|
||||
(if buffer-read-only "[RO]"))
|
||||
:face mode-line-is-modified
|
||||
:when (not (string-prefix-p "*" (buffer-name)))
|
||||
:skip-alternate t
|
||||
:tight t)
|
||||
(spaceline-define-segment *buffer-modified
|
||||
(concat
|
||||
(when buffer-file-name
|
||||
(concat
|
||||
(when (buffer-modified-p) "[+]")
|
||||
(unless (file-exists-p buffer-file-name) "[!]")))
|
||||
(if buffer-read-only "[RO]"))
|
||||
:face mode-line-is-modified
|
||||
:when (not (string-prefix-p "*" (buffer-name)))
|
||||
:skip-alternate t
|
||||
:tight t)
|
||||
|
||||
(spaceline-define-segment narf-buffer-encoding-abbrev
|
||||
"The line ending convention used in the buffer."
|
||||
(symbol-name buffer-file-coding-system)
|
||||
:when (not (string-match-p "\\(utf-8\\|undecided\\)"
|
||||
(symbol-name buffer-file-coding-system))))
|
||||
(spaceline-define-segment *buffer-encoding-abbrev
|
||||
"The line ending convention used in the buffer."
|
||||
(symbol-name buffer-file-coding-system)
|
||||
:when (not (string-match-p "\\(utf-8\\|undecided\\)"
|
||||
(symbol-name buffer-file-coding-system))))
|
||||
|
||||
(spaceline-define-segment narf-buffer-position
|
||||
"A more vim-like buffer position."
|
||||
(let ((start (window-start))
|
||||
(end (window-end))
|
||||
(pend (point-max)))
|
||||
(if (and (eq start 1)
|
||||
(eq end pend))
|
||||
":All"
|
||||
(let ((perc (/ end 0.01 pend)))
|
||||
(cond ((eq start 1) ":Top")
|
||||
((>= perc 100) ":Bot")
|
||||
(t (format ":%d%%%%" perc))))))
|
||||
:tight t)
|
||||
(spaceline-define-segment *buffer-position
|
||||
"A more vim-like buffer position."
|
||||
(let ((start (window-start))
|
||||
(end (window-end))
|
||||
(pend (point-max)))
|
||||
(if (and (eq start 1)
|
||||
(eq end pend))
|
||||
":All"
|
||||
(let ((perc (/ end 0.01 pend)))
|
||||
(cond ((eq start 1) ":Top")
|
||||
((>= perc 100) ":Bot")
|
||||
(t (format ":%d%%%%" perc))))))
|
||||
:tight t)
|
||||
|
||||
(spaceline-define-segment narf-vc
|
||||
"Version control info"
|
||||
(powerline-raw
|
||||
(concat (replace-regexp-in-string
|
||||
(format "^ %s" (vc-backend buffer-file-name))
|
||||
"" vc-mode)
|
||||
(when buffer-file-name
|
||||
(pcase (vc-state (buffer-file-name))
|
||||
(`up-to-date "")
|
||||
(`edited "*")
|
||||
(`added "+")
|
||||
(`unregistered "?")
|
||||
(`removed "-")
|
||||
(`needs-merge "%")
|
||||
(`needs-update "^")
|
||||
(`ignored "#")
|
||||
(_ "_")))))
|
||||
:when (and active vc-mode)
|
||||
:face other-face
|
||||
:tight-right t)
|
||||
(spaceline-define-segment *vc
|
||||
"Version control info"
|
||||
(powerline-raw
|
||||
(concat (replace-regexp-in-string
|
||||
(format "^ %s" (vc-backend buffer-file-name))
|
||||
"" vc-mode)
|
||||
(when buffer-file-name
|
||||
(pcase (vc-state (buffer-file-name))
|
||||
(`up-to-date "")
|
||||
(`edited "*")
|
||||
(`added "+")
|
||||
(`unregistered "?")
|
||||
(`removed "-")
|
||||
(`needs-merge "%")
|
||||
(`needs-update "^")
|
||||
(`ignored "#")
|
||||
(_ "_")))))
|
||||
:when (and active vc-mode)
|
||||
:face other-face
|
||||
:tight-right t)
|
||||
|
||||
(spaceline-define-segment narf-env-version
|
||||
"A HUD that shows which part of the buffer is currently visible."
|
||||
narf--env-version
|
||||
:when narf--env-version
|
||||
:skip-alternate t
|
||||
:tight-right t)
|
||||
(spaceline-define-segment *env-version
|
||||
"A HUD that shows which part of the buffer is currently visible."
|
||||
narf--env-version
|
||||
:when narf--env-version
|
||||
:face other-face
|
||||
:skip-alternate t
|
||||
:tight-right t)
|
||||
|
||||
(spaceline-define-segment narf-hud
|
||||
"A HUD that shows which part of the buffer is currently visible."
|
||||
(powerline-hud highlight-face other-face 1)
|
||||
:face other-face
|
||||
:tight-right t)
|
||||
(spaceline-define-segment *hud
|
||||
"A HUD that shows which part of the buffer is currently visible."
|
||||
(powerline-hud highlight-face other-face 1)
|
||||
:face other-face
|
||||
:tight-right t)
|
||||
|
||||
(defface mode-line-count-face nil "")
|
||||
(make-variable-buffer-local 'anzu--state)
|
||||
(spaceline-define-segment narf-anzu
|
||||
"Show the current match number and the total number of matches. Requires
|
||||
(defface mode-line-count-face nil "")
|
||||
(make-variable-buffer-local 'anzu--state)
|
||||
(spaceline-define-segment *anzu
|
||||
"Show the current match number and the total number of matches. Requires
|
||||
anzu to be enabled."
|
||||
(let ((here anzu--current-position)
|
||||
(total anzu--total-matched))
|
||||
(format " %s/%d%s "
|
||||
(anzu--format-here-position here total)
|
||||
total (if anzu--overflow-p "+" "")))
|
||||
:face (if active 'mode-line-count-face 'mode-line-inactive)
|
||||
:when (and (> anzu--total-matched 0) (evil-ex-hl-active-p 'evil-ex-search))
|
||||
:skip-alternate t
|
||||
:tight t)
|
||||
(let ((here anzu--current-position)
|
||||
(total anzu--total-matched))
|
||||
(format " %s/%d%s "
|
||||
(anzu--format-here-position here total)
|
||||
total (if anzu--overflow-p "+" "")))
|
||||
:face (if active 'mode-line-count-face 'mode-line-inactive)
|
||||
:when (and (> anzu--total-matched 0) (evil-ex-hl-active-p 'evil-ex-search))
|
||||
:skip-alternate t
|
||||
:tight t)
|
||||
|
||||
;; TODO mode-line-iedit-face default face
|
||||
(spaceline-define-segment narf-iedit
|
||||
"Show the number of matches and what match you're on (or after). Requires
|
||||
;; TODO mode-line-iedit-face default face
|
||||
(spaceline-define-segment *iedit
|
||||
"Show the number of matches and what match you're on (or after). Requires
|
||||
iedit."
|
||||
(let ((this-oc (iedit-find-current-occurrence-overlay))
|
||||
(length (or (ignore-errors (length iedit-occurrences-overlays)) 0)))
|
||||
(format "%s/%s"
|
||||
(save-excursion
|
||||
(unless this-oc
|
||||
(iedit-prev-occurrence)
|
||||
(setq this-oc (iedit-find-current-occurrence-overlay)))
|
||||
(if this-oc
|
||||
;; NOTE: Not terribly reliable
|
||||
(- length (-elem-index this-oc iedit-occurrences-overlays))
|
||||
"-"))
|
||||
length))
|
||||
:face (if active 'mode-line-count-face 'mode-line-inactive)
|
||||
:skip-alternate t
|
||||
:when (bound-and-true-p iedit-mode))
|
||||
(let ((this-oc (iedit-find-current-occurrence-overlay))
|
||||
(length (or (ignore-errors (length iedit-occurrences-overlays)) 0)))
|
||||
(format "%s/%s"
|
||||
(save-excursion
|
||||
(unless this-oc
|
||||
(iedit-prev-occurrence)
|
||||
(setq this-oc (iedit-find-current-occurrence-overlay)))
|
||||
(if this-oc
|
||||
;; NOTE: Not terribly reliable
|
||||
(- length (-elem-index this-oc iedit-occurrences-overlays))
|
||||
"-"))
|
||||
length))
|
||||
:when (bound-and-true-p iedit-mode)
|
||||
:face (if active 'mode-line-count-face 'mode-line-inactive)
|
||||
:skip-alternate t)
|
||||
|
||||
;; TODO mode-line-substitute-face default face
|
||||
(defface mode-line-substitute-face nil "")
|
||||
;; TODO This is very hackish; refactor?
|
||||
(spaceline-define-segment narf-evil-substitute
|
||||
"Show number of :s matches in real time."
|
||||
(let ((range (if evil-ex-range
|
||||
(cons (car evil-ex-range) (cadr evil-ex-range))
|
||||
(cons (line-beginning-position) (line-end-position))))
|
||||
(pattern (car-safe (evil-delimited-arguments evil-ex-argument 2))))
|
||||
(if pattern
|
||||
(format "%s matches"
|
||||
(count-matches pattern (car range) (cdr range))
|
||||
evil-ex-argument)
|
||||
" ... "))
|
||||
:face (if active 'mode-line-count-face 'mode-line-inactive)
|
||||
:skip-alternate t
|
||||
:when (and (evil-ex-p) (evil-ex-hl-active-p 'evil-ex-substitute)))
|
||||
(defface mode-line-substitute-face nil "")
|
||||
(spaceline-define-segment *evil-substitute
|
||||
"Show number of :s matches in real time."
|
||||
(let ((range (if evil-ex-range
|
||||
(cons (car evil-ex-range) (cadr evil-ex-range))
|
||||
(cons (line-beginning-position) (line-end-position))))
|
||||
(pattern (car-safe (evil-delimited-arguments evil-ex-argument 2))))
|
||||
(if pattern
|
||||
(format "%s matches"
|
||||
(count-matches pattern (car range) (cdr range))
|
||||
evil-ex-argument)
|
||||
" ... "))
|
||||
:when (and (evil-ex-p) (evil-ex-hl-active-p 'evil-ex-substitute))
|
||||
:face (if active 'mode-line-count-face 'mode-line-inactive)
|
||||
:skip-alternate t)
|
||||
|
||||
(spaceline-define-segment narf-major-mode
|
||||
(powerline-raw mode-name)
|
||||
:tight-right t
|
||||
:skip-alternate t)
|
||||
(spaceline-define-segment *macro-recording
|
||||
"Show when recording macro"
|
||||
(format "%s ▶" (char-to-string evil-this-macro))
|
||||
:when (and active defining-kbd-macro)
|
||||
:face highlight-face
|
||||
:skip-alternate t)
|
||||
|
||||
(spaceline-define-segment *major-mode
|
||||
(powerline-raw
|
||||
(concat
|
||||
mode-name
|
||||
mode-line-process))
|
||||
:tight-right t)
|
||||
|
||||
(spaceline-define-segment *buffer-size
|
||||
(powerline-buffer-size)
|
||||
:tight-right t
|
||||
:skip-alternate t)
|
||||
|
||||
(spaceline-define-segment *remote-host
|
||||
"Hostname for remote buffers."
|
||||
(concat "@" (file-remote-p default-directory 'host))
|
||||
:when (file-remote-p default-directory 'host))
|
||||
|
||||
(defun narf--col-at-pos (pos)
|
||||
(save-excursion (goto-char pos) (current-column)))
|
||||
(spaceline-define-segment *selection-info
|
||||
"Information about the size of the current selection, when applicable.
|
||||
Supports both Emacs and Evil cursor conventions."
|
||||
(let ((reg-beg (region-beginning))
|
||||
(reg-end (region-end)))
|
||||
(let* ((lines (count-lines reg-beg (min (1+ reg-end) (point-max))))
|
||||
(chars (- (1+ reg-end) reg-beg))
|
||||
(cols (1+ (abs (- (narf--col-at-pos reg-end)
|
||||
(narf--col-at-pos reg-beg)))))
|
||||
(evil (eq 'visual evil-state))
|
||||
(rect (or (bound-and-true-p rectangle-mark-mode)
|
||||
(and evil (eq 'block evil-visual-selection))))
|
||||
(multi-line (or (> lines 1) (eq 'line evil-visual-selection))))
|
||||
(cond
|
||||
(rect (format "%dx%d block" lines (if evil cols (1- cols))))
|
||||
(multi-line (format "%d lines" lines))
|
||||
(t (format "%d chars" (if evil chars (1- chars)))))))
|
||||
:when (or mark-active (eq 'visual evil-state))
|
||||
:face highlight-face
|
||||
:skip-alternate t)
|
||||
|
||||
(defun narf--flycheck-count (state)
|
||||
"Return flycheck information for the given error type STATE."
|
||||
(let* ((counts (flycheck-count-errors flycheck-current-errors))
|
||||
(errorp (flycheck-has-current-errors-p state))
|
||||
(running (eq 'running flycheck-last-status-change))
|
||||
(err (cdr (assq state counts))))
|
||||
(when errorp (if running "?" err))))
|
||||
|
||||
(defface spaceline-flycheck-error
|
||||
'((t (:foreground "#FC5C94" :distant-foreground "#A20C41")))
|
||||
"Face for flycheck error feedback in the modeline.")
|
||||
(defface spaceline-flycheck-warning
|
||||
'((t (:foreground "#F3EA98" :distant-foreground "#968B26")))
|
||||
"Face for flycheck warning feedback in the modeline.")
|
||||
(defface spaceline-flycheck-info
|
||||
'((t (:foreground "#8DE6F7" :distant-foreground "#21889B")))
|
||||
"Face for flycheck info feedback in the modeline.")
|
||||
|
||||
(defvar narf--flycheck-err-cache nil "")
|
||||
(defvar narf--flycheck-cache nil "")
|
||||
(spaceline-define-segment *flycheck
|
||||
"Persistent and cached flycheck indicators in the mode-line."
|
||||
(or (and (or (eq narf--flycheck-err-cache narf--flycheck-cache)
|
||||
(memq flycheck-last-status-change '(running not-checked)))
|
||||
narf--flycheck-cache)
|
||||
(and (setq narf--flycheck-err-cache flycheck-current-errors)
|
||||
(setq narf--flycheck-cache
|
||||
(let ((fe (narf--flycheck-count 'error))
|
||||
(fw (narf--flycheck-count 'warning))
|
||||
(fi (narf--flycheck-count 'info)))
|
||||
(concat
|
||||
(when fe (powerline-raw (format " ⚠%s " fe) 'spaceline-flycheck-error))
|
||||
(when fw (powerline-raw (format " ⚠%s " fw) 'spaceline-flycheck-warning))
|
||||
(when fi (powerline-raw (format " ⚠%s " fi) 'spaceline-flycheck-info)))))))
|
||||
:when (and (bound-and-true-p flycheck-mode)
|
||||
(or flycheck-current-errors
|
||||
(eq 'running flycheck-last-status-change)))
|
||||
:tight-left t))
|
||||
|
||||
;; Initialize modeline
|
||||
(spaceline-install
|
||||
;; Left side
|
||||
'(narf-anzu narf-iedit narf-evil-substitute
|
||||
(narf-buffer-path remote-host)
|
||||
narf-buffer-modified
|
||||
narf-vc
|
||||
((flycheck-error flycheck-warning flycheck-info) :when active))
|
||||
'(*macro-recording
|
||||
(*flycheck :fallback *buffer-size)
|
||||
(*anzu *iedit *evil-substitute)
|
||||
(*buffer-path *remote-host)
|
||||
*buffer-modified
|
||||
*vc
|
||||
)
|
||||
;; Right side
|
||||
'((selection-info :face highlight-face :skip-alternate t :when active)
|
||||
narf-env-version
|
||||
narf-buffer-encoding-abbrev
|
||||
(narf-major-mode
|
||||
;; (minor-modes :separator " " :tight t)
|
||||
(process :tight t))
|
||||
'(*selection-info
|
||||
*buffer-encoding-abbrev
|
||||
*major-mode
|
||||
*env-version
|
||||
(global :when active)
|
||||
("%l·%c" narf-buffer-position)
|
||||
narf-hud
|
||||
("%l/%c" *buffer-position)
|
||||
*hud
|
||||
)))
|
||||
|
||||
(provide 'core-ui)
|
||||
|
|
|
@ -9,23 +9,21 @@
|
|||
"/\\.git/info/exclude$"
|
||||
"/git/ignore$"))
|
||||
|
||||
(use-package github-browse-file
|
||||
:commands (github-browse-file github-browse-file-blame)
|
||||
(use-package browse-at-remote
|
||||
:defer t
|
||||
:init
|
||||
(evil-define-command narf:github-browse-file (&optional bang)
|
||||
(interactive "<!>")
|
||||
(if bang (github-browse-file-blame) (github-browse-file))))
|
||||
(browse-at-remote bang)))
|
||||
|
||||
(use-package git-gutter
|
||||
:commands (git-gutter-mode narf/vcs-next-hunk narf/vcs-prev-hunk
|
||||
narf/vcs-show-hunk narf/vcs-stage-hunk narf/vcs-revert-hunk)
|
||||
:init
|
||||
(add-hook! (text-mode prog-mode) 'git-gutter-mode)
|
||||
(add-hook! (text-mode prog-mode conf-mode) 'git-gutter-mode)
|
||||
:config
|
||||
(require 'git-gutter-fringe)
|
||||
|
||||
(setq git-gutter:update-interval 2)
|
||||
|
||||
(defalias 'narf/vcs-next-hunk 'git-gutter:next-hunk)
|
||||
(defalias 'narf/vcs-prev-hunk 'git-gutter:previous-hunk)
|
||||
(defalias 'narf/vcs-show-hunk 'git-gutter:popup-hunk)
|
||||
|
@ -43,9 +41,7 @@
|
|||
nil nil 'center)
|
||||
|
||||
(advice-add 'evil-force-normal-state :after 'git-gutter)
|
||||
|
||||
(add-hook! focus-in 'git-gutter:update-all-windows)
|
||||
(add-hook! evil-insert-state-exit 'git-gutter))
|
||||
(add-hook! focus-in 'git-gutter:update-all-windows))
|
||||
|
||||
(use-package diff-hl
|
||||
:disabled t
|
||||
|
@ -53,11 +49,11 @@
|
|||
(setq diff-hl-draw-borders nil
|
||||
diff-hl-fringe-bmp-function 'narf-diff-hl-fringe-bmp)
|
||||
:config
|
||||
(defalias narf/vcs-next-hunk 'diff-hl-next-hunk)
|
||||
(defalias narf/vcs-prev-hunk 'diff-hl-previous-hunk)
|
||||
;; (defalias narf/vcs-show-hunk
|
||||
;; (defalias narf/vcs-stage-hunk ...)
|
||||
(defalias narf/vcs-revert-hunk 'diff-hl-revert-hunk)
|
||||
(defalias 'narf/vcs-next-hunk 'diff-hl-next-hunk)
|
||||
(defalias 'narf/vcs-prev-hunk 'diff-hl-previous-hunk)
|
||||
;; (defalias 'narf/vcs-show-hunk
|
||||
;; (defalias 'narf/vcs-stage-hunk ...)
|
||||
(defalias 'narf/vcs-revert-hunk 'diff-hl-revert-hunk)
|
||||
|
||||
(defun narf-diff-hl-fringe-bmp (type _pos)
|
||||
(if (eq type 'delete)
|
||||
|
@ -76,5 +72,18 @@
|
|||
|
||||
(global-diff-hl-mode 1))
|
||||
|
||||
(after! vc-annotate
|
||||
(evil-set-initial-state 'vc-annotate-mode 'normal)
|
||||
(evil-set-initial-state 'vc-git-log-view-mode 'normal)
|
||||
(map! :map vc-annotate-mode-map
|
||||
:n "q" 'kill-this-buffer
|
||||
:n "d" 'vc-annotate-show-diff-revision-at-line
|
||||
:n "D" 'vc-annotate-show-changeset-diff-revision-at-line
|
||||
:n "SPC" 'vc-annotate-show-log-revision-at-line
|
||||
:n "]]" 'vc-annotate-next-revision
|
||||
:n "[[" 'vc-annotate-prev-revision
|
||||
:n [tab] 'vc-annotate-toggle-annotation-visibility
|
||||
:n "RET" 'vc-annotate-find-revision-at-line))
|
||||
|
||||
(provide 'core-vcs)
|
||||
;;; core-vcs.el ends here
|
||||
|
|
|
@ -10,14 +10,14 @@
|
|||
wg-first-wg-name "*untitled*"
|
||||
wg-session-load-on-start t
|
||||
wg-mode-line-display-on nil
|
||||
wg-mess-with-buffer-list t
|
||||
wg-mess-with-buffer-list nil
|
||||
wg-emacs-exit-save-behavior 'save ; Options: 'save 'ask nil
|
||||
wg-workgroups-mode-exit-save-behavior 'save
|
||||
wg-log-level 0
|
||||
|
||||
wg-list-display-decor-divider " "
|
||||
wg-list-display-decor-left-brace ""
|
||||
wg-list-display-decor-right-brace ""
|
||||
wg-list-display-decor-right-brace "| "
|
||||
wg-list-display-decor-current-left ""
|
||||
wg-list-display-decor-current-right ""
|
||||
wg-list-display-decor-previous-left ""
|
||||
|
@ -31,9 +31,12 @@
|
|||
(candidates . wg-workgroup-names)
|
||||
(action . narf/wg-helm-switch-to-workgroup)))
|
||||
|
||||
(add-to-list 'savehist-additional-variables 'narf-wg-names)
|
||||
(defvar narf-wg-frames '())
|
||||
(defvar narf-wg-names '())
|
||||
(add-to-list 'savehist-additional-variables 'narf-wg-names)
|
||||
|
||||
(unless (file-exists-p wg-workgroup-directory)
|
||||
(mkdir wg-workgroup-directory))
|
||||
|
||||
(after! projectile
|
||||
;; Create a new workgroup on switch-project
|
||||
|
|
|
@ -138,7 +138,7 @@
|
|||
|
||||
(defun display-startup-echo-area-message ()
|
||||
(after! workgroups2
|
||||
(message "%s Loaded in %s" (narf/workgroup-display t t) (emacs-init-time))))
|
||||
(message "%sLoaded in %s" (narf/workgroup-display t t) (emacs-init-time))))
|
||||
|
||||
(require 'server)
|
||||
(unless (server-running-p)
|
||||
|
|
|
@ -39,7 +39,7 @@ Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/"
|
|||
(defun narf/get-all-buffers ()
|
||||
"Get all buffers across all workgroups. Depends on
|
||||
`wg-mess-with-buffer-list'."
|
||||
(if (and (featurep 'workgroups2) workgroups-mode)
|
||||
(if (and (featurep 'workgroups2) workgroups-mode wg-mess-with-buffer-list)
|
||||
(wg-buffer-list-emacs)
|
||||
(buffer-list)))
|
||||
|
||||
|
@ -47,7 +47,7 @@ Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/"
|
|||
(defun narf/get-buffers ()
|
||||
"Get all buffers in the current workgroup. Depends on
|
||||
`wg-mess-with-buffer-list'."
|
||||
(buffer-list))
|
||||
(wg-workgroup-associated-buffers (wg-current-workgroup)))
|
||||
|
||||
;;;###autoload
|
||||
(defun narf/get-visible-buffers (&optional buffer-list)
|
||||
|
|
|
@ -39,16 +39,5 @@
|
|||
(beginning-of-line))
|
||||
(setq *linum-mdown-line* nil))))
|
||||
|
||||
;;;###autoload (autoload 'narf:align "defuns-editor" nil t)
|
||||
(evil-define-operator narf:align (&optional beg end bang pattern)
|
||||
(interactive "<r><!><//>")
|
||||
(align-regexp
|
||||
beg end
|
||||
(concat "\\(\\s-*\\)"
|
||||
(if bang
|
||||
(regexp-quote pattern)
|
||||
(rxt-pcre-to-elisp pattern)))
|
||||
1 1))
|
||||
|
||||
(provide 'defuns-editor)
|
||||
;;; defuns-editor.el ends here
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
(defun narf/helm-buffers-dwim (&optional all-p)
|
||||
"Displays open buffers in current project. If ALL-P, then show all open
|
||||
buffers."
|
||||
(interactive)
|
||||
(if (and (not all-p) (narf/project-p))
|
||||
(helm-projectile-switch-to-buffer)
|
||||
(helm-buffers-list)))
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
;;;###autoload
|
||||
(defun narf|spaceline-env-update ()
|
||||
(when narf--env-command
|
||||
(let* ((command (format "cd '%s' && %s" (narf/project-root) narf--env-command))
|
||||
(s (shell-command-to-string command)))
|
||||
(setq narf--env-version (if (string-match "[ \t\n\r]+\\'" s)
|
||||
(replace-match "" t t s)
|
||||
s)))))
|
||||
(let ((default-directory (narf/project-root)))
|
||||
(let ((s (shell-command-to-string narf--env-command)))
|
||||
(setq narf--env-version (if (string-match "[ \t\n\r]+\\'" s)
|
||||
(replace-match "" t t s)
|
||||
s))))))
|
||||
|
||||
(provide 'defuns-spaceline)
|
||||
;;; defuns-spaceline.el ends here
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
(defun narf/wg-projectile-switch-project ()
|
||||
(let ((workgroup-name (file-name-nondirectory (directory-file-name (narf/project-root)))))
|
||||
(wg-create-workgroup workgroup-name t)
|
||||
(helm-projectile-find-file)))
|
||||
(helm-projectile-find-file)
|
||||
;; TODO narf/workgroup-display?
|
||||
))
|
||||
|
||||
;;;###autoload (autoload 'narf:save-session "defuns-workgroup" nil t)
|
||||
(evil-define-command narf:save-session (&optional bang session-name)
|
||||
|
@ -41,14 +43,23 @@
|
|||
(wg-clone-workgroup (wg-current-workgroup) name)
|
||||
(wg-create-workgroup name t))
|
||||
(unless silent
|
||||
(narf/workgroup-display (wg-previous-workgroup))))
|
||||
(narf--workgroup-display (wg-previous-workgroup)
|
||||
(format "Created %s" name)
|
||||
'success)))
|
||||
|
||||
;;;###autoload (autoload 'narf:workgroup-rename "defuns-workgroup" nil t)
|
||||
(evil-define-command narf:workgroup-rename (new-name)
|
||||
(interactive "<a>")
|
||||
(let ((wg (wg-current-workgroup)))
|
||||
(wg-rename-workgroup new-name wg)
|
||||
(add-to-list 'narf-wg-names wg)))
|
||||
(evil-define-command narf:workgroup-rename (bang &optional new-name)
|
||||
(interactive "<!><a>")
|
||||
(let* ((wg (wg-current-workgroup))
|
||||
(wg-uid (wg-workgroup-uid wg))
|
||||
(old-name (wg-workgroup-name wg)))
|
||||
(if bang
|
||||
(setq narf-wg-names (delete wg-uid narf-wg-names))
|
||||
(unless new-name
|
||||
(user-error "You didn't enter in a name"))
|
||||
(wg-rename-workgroup new-name wg)
|
||||
(add-to-list 'narf-wg-names wg-uid)
|
||||
(narf--workgroup-display wg (format "Renamed '%s'->'%s'" old-name new-name) 'success))))
|
||||
|
||||
;;;###autoload (autoload 'narf:workgroup-delete "defuns-workgroup" nil t)
|
||||
(evil-define-command narf:workgroup-delete (&optional bang name)
|
||||
|
@ -61,7 +72,7 @@
|
|||
(if (eq wg current-wg)
|
||||
(wg-kill-workgroup)
|
||||
(wg-delete-workgroup wg))
|
||||
(message "%s [Deleted %s]" (narf/workgroup-display nil t) wg-name))))
|
||||
(narf--workgroup-display nil (format "Deleted %s" wg-name) 'success))))
|
||||
|
||||
;;;###autoload
|
||||
(defun narf:kill-other-workgroups ()
|
||||
|
@ -72,6 +83,24 @@
|
|||
(unless (wg-current-workgroup-p w)
|
||||
(wg-kill-workgroup w)))))
|
||||
|
||||
(defun narf--num-to-unicode (num)
|
||||
"Return a nice unicode representation of a single-digit number STR."
|
||||
(cl-case num
|
||||
(1 "➊")
|
||||
(2 "➋")
|
||||
(3 "➌")
|
||||
(4 "➍")
|
||||
(5 "➎")
|
||||
(6 "❻")
|
||||
(7 "➐")
|
||||
(8 "➑")
|
||||
(9 "➒")
|
||||
(0 "➓")))
|
||||
|
||||
(defun narf--workgroup-display (&optional suppress-update message message-face)
|
||||
(message "%s%s" (narf/workgroup-display suppress-update t)
|
||||
(propertize message 'face message-face)))
|
||||
|
||||
;;;###autoload
|
||||
(defun narf/workgroup-display (&optional suppress-update return-p)
|
||||
(interactive)
|
||||
|
@ -83,7 +112,7 @@
|
|||
(if (not workgroup) wg-nowg-string
|
||||
(wg-element-display
|
||||
workgroup
|
||||
(format " (%d) %s " (1+ index) (wg-workgroup-name workgroup))
|
||||
(format " %s %s " (narf--num-to-unicode (1+ index)) (wg-workgroup-name workgroup))
|
||||
'wg-current-workgroup-p)))
|
||||
(wg-workgroup-list))))
|
||||
(if return-p
|
||||
|
@ -99,23 +128,24 @@
|
|||
(base (f-filename (buffer-file-name))))
|
||||
(unless (string= base old-name)
|
||||
(wg-rename-workgroup base wg)))))))
|
||||
;; (advice-add 'select-window :after 'narf|workgroup-update-name)
|
||||
|
||||
;;;###autoload (autoload 'narf:switch-to-workgroup-left "defuns-workgroup" nil t)
|
||||
(evil-define-command narf:switch-to-workgroup-left (count)
|
||||
(interactive "<c>")
|
||||
(narf/workgroup-update-names)
|
||||
(if count
|
||||
(wg-switch-to-workgroup-at-index (1- count))
|
||||
(wg-switch-to-workgroup-left))
|
||||
(narf/workgroup-display (wg-previous-workgroup)))
|
||||
(narf/workgroup-display t))
|
||||
|
||||
;;;###autoload (autoload 'narf:switch-to-workgroup-right "defuns-workgroup" nil t)
|
||||
(evil-define-command narf:switch-to-workgroup-right (count)
|
||||
(interactive "<c>")
|
||||
(narf/workgroup-update-names)
|
||||
(if count
|
||||
(wg-switch-to-workgroup-at-index (1- count))
|
||||
(wg-switch-to-workgroup-right))
|
||||
(narf/workgroup-display (wg-previous-workgroup)))
|
||||
(narf/workgroup-display t))
|
||||
|
||||
;;;###autoload
|
||||
(defun narf:switch-to-workgroup-at-index (index)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue