Fix flycheck warnings

This commit is contained in:
Wojciech Kozlowski 2018-07-07 21:34:00 +01:00
parent 46273c0718
commit e0b70e0948
15 changed files with 379 additions and 254 deletions

View File

@ -24,7 +24,8 @@
;;; Code:
(require 'package)
(require 'cl)
(with-no-warnings
(require 'cl))
(defgroup emodule nil
"Further automate working with `package'"
@ -63,15 +64,13 @@ after attempting to install all other packages first."
;;; Print functions
(defun emodule/set-logs-read-only ()
"Set log buffer to log-view-mode."
"Set log buffer to `log-view-mode'."
(when emodule/print-logs
(save-excursion
(set-buffer (get-buffer-create emodule/log))
(with-current-buffer (get-buffer-create emodule/log)
(log-view-mode))
(save-excursion
(set-buffer (get-buffer-create emodule/error-log))
(with-current-buffer (get-buffer-create emodule/error-log)
(log-view-mode))))
(defun emodule/erase-logs ()
@ -79,15 +78,13 @@ after attempting to install all other packages first."
(when emodule/print-logs
;; Erase `emodule/log'.
(save-excursion
(set-buffer (get-buffer-create emodule/log))
(with-current-buffer (get-buffer-create emodule/log)
(read-only-mode 0)
(erase-buffer)
(goto-char (point-min)))
;; Erase `emodule/error-log'.
(save-excursion
(set-buffer (get-buffer-create emodule/error-log))
(with-current-buffer (get-buffer-create emodule/error-log)
(read-only-mode 0)
(erase-buffer)
(goto-char (point-min)))))
@ -95,15 +92,14 @@ after attempting to install all other packages first."
(defun emodule/print (string buffer)
"Print STRING to BUFFER."
(when emodule/print-logs
(save-excursion
(set-buffer (get-buffer-create buffer))
(with-current-buffer (get-buffer-create buffer)
(goto-char (point-max))
(if (not (= (point) 1))
(newline))
(insert string))))
(defun emodule/print-format (fmt pkg buffer)
"Print string of FMT about PKG to BUFFER"
"Print string of FMT about PKG to BUFFER."
(or (stringp pkg)
(setq pkg (symbol-name pkg)))
(emodule/print (format fmt pkg) buffer))
@ -117,7 +113,7 @@ after attempting to install all other packages first."
(emodule/print-format "Deleting: %s" pkg emodule/log))
(defun emodule/print-failed (logstrbase pkg)
"Print a log message about failed operation of PKG."
"Print a log message LOGSTRBASE about failed operation of PKG."
(let* ((logstr (concat logstrbase
(format " (see %s for details)"
emodule/error-log)))
@ -205,7 +201,8 @@ DESIRED-PKGS unless NO-SET-SELECTED is non-nil"
;; Install packages. If any packages fail to install, re-attempt up to
;; `emodule/install-attempts' total attempts.
(let ((attempt 0))
(let ((attempt 0)
(install-pkgs nil))
(while (and (< attempt emodule/install-attempts)
(setq install-pkgs
(remove-if #'package-installed-p desired-pkgs)))

32
init.el
View File

@ -9,6 +9,10 @@
;;
;;; License: GPLv3
;;; Commentary:
;;; Code:
;; ----------------------------------------------------------------------------
;; Run init without garbage collection.
;; ----------------------------------------------------------------------------
@ -87,24 +91,25 @@
(add-to-list 'load-path "~/.emacs.d/emodule")
(require 'emodule)
(declare-function emodule/init "emodule")
;; --------------------------------------------------------------------------
;; Load modules.
;; --------------------------------------------------------------------------
(emodule/init '(
editing
emacs
files
helm
helm-gtags
modeline
org
parentheses
programming
terminal
version-control
workflow
em-editing
em-emacs
em-files
em-helm
em-helm-gtags
em-modeline
em-org
em-parentheses
em-programming
em-terminal
em-version-control
em-workflow
))
@ -129,3 +134,6 @@
(load custom-file 'noerror)
) ;; Reset garbage collection settings.
(provide 'init)
;;; init.el ends here

View File

@ -1,4 +1,4 @@
;;; editing.el --- Module file for editing configuration.
;;; em-editing.el --- Module file for editing configuration.
;;
;; Copyright (C) 2017 Wojciech Kozlowski
;;
@ -15,21 +15,24 @@
;;; Required packages:
(setq emodule/editing-packages
;;; Code:
'(duplicate-thing
expand-region
fill-column-indicator
undo-tree
volatile-highlights
whole-line-or-region
ws-butler)
(defvar emodule/em-editing-packages
)
'(duplicate-thing
expand-region
fill-column-indicator
undo-tree
volatile-highlights
whole-line-or-region
ws-butler)
)
;; Configuration:
(defun emodule/editing-init ()
(defun emodule/em-editing-init ()
"Initialise the `em-editing' module."
;; --------------------------------------------------------------------------
;; Duplicate things.
@ -214,15 +217,20 @@
"Indent the currently visited buffer."
(interactive)
(indent-region (point-min) (point-max)))
(declare-function indent-buffer "editing")
(defcustom indent-sensitive-modes
'(coffee-mode python-mode slim-mode haml-mode yaml-mode)
"Modes for which auto-indenting is suppressed."
:type 'list)
:type 'list
:group 'wk/editing)
(defun indent-region-or-buffer ()
"Indent a region if selected, otherwise the whole buffer."
(interactive)
(defvar indent-sensitive-modes)
(unless (member major-mode indent-sensitive-modes)
(save-excursion
(if (region-active-p)
@ -252,3 +260,6 @@
(global-set-key (kbd "M-s M-o") 'occur)
)
(provide 'em-editing)
;;; em-editing.el ends here

View File

@ -1,4 +1,4 @@
;;; emacs.el --- Module file for configuring Emacs itself.
;;; em-emacs.el --- Module file for configuring Emacs itself.
;;
;; Copyright (C) 2017 Wojciech Kozlowski
;;
@ -15,24 +15,27 @@
;;; Required packages:
(setq emodule/emacs-packages
;;; Code:
'(discover-my-major
help+
help-fns+
help-mode+
ibuffer-vc
info+
rainbow-mode
sr-speedbar
which-key
use-package)
(defvar emodule/em-emacs-packages
)
'(discover-my-major
help+
help-fns+
help-mode+
ibuffer-vc
info+
rainbow-mode
sr-speedbar
which-key
use-package)
)
;;; Configuration:
(defun emodule/emacs-init ()
(defun emodule/em-emacs-init ()
"Initialise the `em-emacs' module."
;; --------------------------------------------------------------------------
;; Help extensions.
@ -67,9 +70,10 @@
:init
(add-hook 'ibuffer-hook
(lambda ()
(declare-function ibuffer-do-sort-by-alphabetic "ibuf-ext")
(ibuffer-vc-set-filter-groups-by-vc-root)
(unless (eq ibuffer-sorting-mode 'alphabetic)
((insert )buffer-do-sort-by-alphabetic))))
(ibuffer-do-sort-by-alphabetic))))
:config
(setq ibuffer-formats
'((mark modified read-only vc-status-mini " "
@ -104,6 +108,7 @@
(if (window-live-p sr-speedbar-window)
(set-frame-selected-window (window-frame) sr-speedbar-window)
(user-error "Speedbar window is not live")))
(declare-function goto-speedbar "emacs")
(global-set-key (kbd "M-m") #'goto-speedbar))
@ -139,6 +144,8 @@
This has to be called whenever the active theme changes to
refresh these colours."
(defvar highlight-parentheses-mode)
(when (and (fboundp 'fci-mode)
(member 'fci-mode minor-mode-list))
(fci-mode 1))
@ -146,6 +153,7 @@
(when (and (fboundp 'highlight-parentheses-mode)
highlight-parentheses-mode)
(highlight-parentheses-mode 1)))
(declare-function refresh-non-face-colours "emacs")
;; Key-bindings -------------------------------------------------------------
@ -234,9 +242,11 @@
(defun minibuffer-gc-setup-hook ()
(setq gc-cons-threshold most-positive-fixnum))
(declare-function minibuffer-gc-setup-hook "emacs")
(defun minibuffer-gc-exit-hook ()
(setq gc-cons-threshold 800000))
(declare-function minibuffer-gc-exit-hook "emacs")
(add-hook 'minibuffer-setup-hook #'minibuffer-gc-setup-hook)
(add-hook 'minibuffer-exit-hook #'minibuffer-gc-exit-hook)
@ -253,3 +263,6 @@
(setq-default auto-window-vscroll nil)
)
(provide 'em-emacs)
;;; em-emacs.el ends here

View File

@ -1,4 +1,4 @@
;;; files.el --- Module file for configuring file management.
;;; em-files.el --- Module file for configuring file management.
;;
;; Copyright (C) 2017 Wojciech Kozlowski
;;
@ -15,16 +15,19 @@
;;; Required packages:
(setq emodule/files-packages
;;; Code:
'(recentf-ext
vlf)
(defvar emodule/em-files-packages
)
'(recentf-ext
vlf)
)
;;; Configuration:
(defun emodule/files-init ()
(defun emodule/em-files-init ()
"Initialise the `em-files' module."
;; --------------------------------------------------------------------------
;; View large files.
@ -116,3 +119,6 @@
(save-place-mode 1))
)
(provide 'em-files)
;;; em-files.el ends here

View File

@ -1,4 +1,4 @@
;;; helm-gtags.el --- Module file for GTAGS with Helm configuration.
;;; em-helm-gtags.el --- Module file for GTAGS with Helm configuration.
;;
;; Copyright (C) 2017 Wojciech Kozlowski
;;
@ -27,15 +27,18 @@
;;; Required packages:
(setq emodule/helm-gtags-packages
;;; Code:
'(helm-gtags)
(defvar emodule/em-helm-gtags-packages
)
'(helm-gtags)
)
;;; Configuration:
(defun emodule/helm-gtags-init ()
(defun emodule/em-helm-gtags-init ()
"Initialise the `em-helm-gtags' module."
(use-package helm-gtags
:defer t
@ -63,3 +66,6 @@
(define-key helm-gtags-mode-map (kbd "C-c <") 'helm-gtags-previous-history)
(define-key helm-gtags-mode-map (kbd "C-c >") 'helm-gtags-next-history))
)
(provide 'em-helm-gtags)
;;; em-helm-gtags.el ends here

View File

@ -1,4 +1,4 @@
;;; helm.el --- Module file for Helm configuration.
;;; em-helm.el --- Module file for Helm configuration.
;;
;; Copyright (C) 2017 Wojciech Kozlowski
;;
@ -15,18 +15,21 @@
;;; Required packages:
(setq emodule/helm-packages
;;; Code:
'(helm
helm-descbinds
helm-projectile
swiper-helm)
(defvar emodule/em-helm-packages
)
'(helm
helm-descbinds
helm-projectile
swiper-helm)
)
;;; Configuration:
(defun emodule/helm-init ()
(defun emodule/em-helm-init ()
"Initialise the `em-helm' module."
(use-package helm
:init
@ -40,6 +43,8 @@
("C-h SPC" . helm-all-mark-rings))
:config
(require 'helm-config)
(declare-function helm-autoresize-mode "helm")
(declare-function helm-buffer-get "helm-lib")
;; Helm prefix ------------------------------------------------------------
@ -119,7 +124,7 @@
(use-package helm-projectile
:init
(projectile-global-mode)
(projectile-mode)
:config
(setq-default projectile-completion-system 'helm)
(helm-projectile-on))
@ -130,3 +135,6 @@
(("C-c h C-s" . swiper-helm))))
)
(provide 'em-helm)
;;; em-helm.el ends here

View File

@ -1,4 +1,4 @@
;;; modeline.el --- Module file for configuring the modeline.
;;; em-modeline.el --- Module file for configuring the modeline.
;;
;; Copyright (C) 2018 Wojciech Kozlowski
;;
@ -15,18 +15,19 @@
;;; Required packages:
(setq emodule/modeline-packages
;;; Code:
'(
all-the-icons
doom-modeline
)
(defvar emodule/em-modeline-packages
)
'(all-the-icons
doom-modeline)
)
;;; Configuration:
(defun emodule/modeline-init ()
(defun emodule/em-modeline-init ()
"Initialise the `em-modeline' module."
;; Note that doom-modeline requires all-the-icons which in turn require the
;; user to manually install the fonts with the command `M-x
@ -39,3 +40,6 @@
(after-init . doom-modeline-init))
)
(provide 'em-modeline)
;;; em-modeline.el ends here

View File

@ -1,4 +1,4 @@
;;; org.el --- Module file for org-mode configuration.
;;; em-org.el --- Module file for org-mode configuration.
;;
;; Copyright (C) 2017 Wojciech Kozlowski
;;
@ -15,15 +15,19 @@
;;; Required packages:
(setq emodule/org-packages
;;; Code:
'(org-bullets)
)
(defvar emodule/em-org-packages
'(org-bullets)
)
;; Configuration:
(defun emodule/org-init ()
(defun emodule/em-org-init ()
"Initialise the `em-org' module."
(use-package org
:config
@ -62,3 +66,6 @@
)
)
(provide 'em-org)
;;; em-org.el ends here

View File

@ -1,4 +1,4 @@
;;; parentheses.el --- Module file for managing parentheses packages.
;;; em-parentheses.el --- Module file for managing parentheses packages.
;;
;; Copyright (C) 2017 Wojciech Kozlowski
;;
@ -16,17 +16,20 @@
;;; Required packages:
(setq emodule/parentheses-packages
;;; Code:
'(highlight-parentheses
rainbow-delimiters
smartparens)
(defvar emodule/em-parentheses-packages
)
'(highlight-parentheses
rainbow-delimiters
smartparens)
)
;; Configuration:
(defun emodule/parentheses-init ()
(defun emodule/em-parentheses-init ()
"Initialise the `em-parentheses' module."
;; --------------------------------------------------------------------------
;; Highlight parentheses - this package does not use faces for colours,
@ -58,6 +61,8 @@
(show-smartparens-global-mode t)
:config
(require 'smartparens-config)
(declare-function sp-local-pair "smartparens")
(declare-function sp-beginning-of-sexp "smartparens")
;; Key-bindings -----------------------------------------------------------
@ -117,3 +122,6 @@
sp-highlight-pair-overlay nil))
)
(provide 'em-parentheses)
;;; em-parentheses.el ends here

View File

@ -1,4 +1,4 @@
;;; programming.el --- Module file for programming configuration.
;;; em-programming.el --- Module file for programming configuration.
;;
;; Copyright (C) 2017 Wojciech Kozlowski
;;
@ -16,37 +16,40 @@
;;; Required packages:
(setq emodule/programming-packages
;;; Code:
'(company
company-c-headers
dockerfile-mode
fic-mode
function-args
flycheck
flycheck-plantuml
flycheck-pos-tip
flycheck-rust
highlight-numbers
highlight-symbol
plantuml-mode
rust-mode
stickyfunc-enhance
swiper
toml-mode
vala-mode
yaml-mode
yasnippet
yasnippet-snippets
(defvar emodule/em-programming-packages
s
f)
'(company
company-c-headers
dockerfile-mode
fic-mode
function-args
flycheck
flycheck-plantuml
flycheck-pos-tip
flycheck-rust
highlight-numbers
highlight-symbol
plantuml-mode
rust-mode
stickyfunc-enhance
swiper
toml-mode
vala-mode
yaml-mode
yasnippet
yasnippet-snippets
)
s
f)
)
;; Configuration:
(defun emodule/programming-init ()
(defun emodule/em-programming-init ()
"Initialise the `em-programming' module."
;; --------------------------------------------------------------------------
;; Company - complete anything.
@ -72,11 +75,13 @@
;; function-args overrides the custom "M-o" binding, this undoes it
(define-key function-args-mode-map (kbd "M-o") nil)
(define-key function-args-mode-map (kbd "M-O") 'moo-complete))
(declare-function set-other-window-key "programming")
(defun set-moo-jump-directory-key ()
;; function-args overrides the default "C-M-k" binding, this undoes it
(define-key function-args-mode-map (kbd "C-M-k") nil)
(define-key function-args-mode-map (kbd "C-M-;") 'moo-jump-directory))
(declare-function set-moo-jump-directory-key "programming")
(defun set-fa-idx-cycle-keys ()
;; function-args overrides the default "M-h" and "M-p" bindings, this
@ -85,11 +90,13 @@
(define-key function-args-mode-map (kbd "M-[") 'fa-idx-cycle-up)
(define-key function-args-mode-map (kbd "M-n") nil)
(define-key function-args-mode-map (kbd "M-]") 'fa-idx-cycle-down))
(declare-function set-fa-idx-cycle-keys "programming")
(defun set-fa-abort-key ()
;; function-args overrides the default "C-M-k" binding, this undoes it
(define-key function-args-mode-map (kbd "M-u") nil)
(define-key function-args-mode-map (kbd "M-k") 'fa-abort))
(declare-function set-fa-abort-key "programming")
(defun set-function-args-keys ()
;; Collects all the function-args key overrides
@ -97,6 +104,7 @@
(set-moo-jump-directory-key)
(set-fa-idx-cycle-keys)
(set-fa-abort-key))
(declare-function set-function-args-keys "programming")
(add-hook 'function-args-mode-hook #'set-function-args-keys))
@ -174,6 +182,7 @@
(unless (= ret 0)
(error err-msg)))))
(declare-function rust-new-project "programming")
(defun rust-new-project-bin (project-name)
(interactive "sBinary project name: ")
@ -194,9 +203,11 @@
(add-to-list 'load-path "~/.emacs.d/emacs-racer")
(use-package racer
:init
(declare-function racer-mode "racer")
(add-hook 'rust-mode-hook #'racer-mode)
(add-hook 'racer-mode-hook #'eldoc-mode)
:config
(declare-function company-indent-or-complete-common "company")
;; For racer to work, it needs to know where to find the standard library
;; sources. The easiest way to do it without having a machine dependent
;; setup is to set the environment variable RUST_SRC_PATH. If that's
@ -285,6 +296,9 @@
;; such as those in `/usr/local/include'.
(use-package semantic
:init
(declare-function global-semanticdb-minor-mode "semantic/db-mode")
(declare-function global-semantic-idle-scheduler-mode "semantic/idle")
(declare-function semantic-mode "semantic")
(global-semanticdb-minor-mode 1)
(global-semantic-idle-scheduler-mode 1)
(semantic-mode 1)
@ -343,6 +357,7 @@
;; ansi-colors
(ignore-errors
(require 'ansi-color)
(declare-function ansi-color-apply-on-region "ansi-color")
(defun my-colorize-compilation-buffer ()
(when (eq major-mode 'compilation-mode)
(ansi-color-apply-on-region compilation-filter-start (point-max))))
@ -446,3 +461,6 @@
(yank-advised-indent-function (region-beginning) (region-end)))))
)
(provide 'em-programming)
;;; em-programming.el ends here

View File

@ -1,4 +1,4 @@
;;; terminal.el --- Module file for terminal configuration.
;;; em-terminal.el --- Module file for terminal configuration.
;;
;; Copyright (C) 2017 Wojciech Kozlowski
;;
@ -16,15 +16,18 @@
;;; Required packages:
(setq emodule/terminal-packages
;;; Code:
'()
(defvar emodule/em-terminal-packages
)
'()
)
;; Configuration:
(defun emodule/terminal-init ()
(defun emodule/em-terminal-init ()
"Initialise the `em-terminal' module."
;; --------------------------------------------------------------------------
;; Configure term.
@ -32,6 +35,9 @@
(use-package term
:config
(declare-function term-send-raw-string "term")
(declare-function term-check-proc "term")
(defun x-term-setup ()
(interactive)
(define-key term-raw-map (kbd "C-y") 'term-send-raw)
@ -63,17 +69,21 @@
(setq ansi-buf (ansi-term term-cmd))
(switch-to-buffer cur-buf)
(switch-to-buffer-other-window ansi-buf)))
(declare-function ansi-term-pop "terminal")
(defun ansi-term-recycle (term-cmd)
"Kill current buffer and start an *ansi-term* in it."
(kill-buffer (current-buffer))
(ansi-term term-cmd))
(declare-function ansi-term-recycle "terminal")
(defun first-matching-buffer (regex)
"Find first buffer whose name matches REGEXP."
(declare-function remove-if-not "cl-seq")
(car (remove-if-not
(apply-partially #'string-match-p regex)
(mapcar 'buffer-name (buffer-list)))))
(declare-function first-matching-buffer "terminal")
(defun visit-ansi-term ()
"Open or switch to active ansi-term.
@ -112,6 +122,9 @@
(use-package eshell
:config
(declare-function eshell "eshell")
(declare-function eshell-send-input "esh-mode")
(defun eshell-pop (name)
"Launch terminal in (preferably) other window."
(let ((esh-buf nil)
@ -119,6 +132,7 @@
(setq esh-buf (eshell name))
(switch-to-buffer cur-buf)
(switch-to-buffer-other-window esh-buf)))
(declare-function eshell-pop "terminal")
(defun eshell-here ()
(interactive)
@ -151,6 +165,7 @@
(if (one-window-p t)
(delete-frame)
(delete-window (selected-window)))))
(declare-function delete-single-window "terminal")
(defun eshell/x (&rest args)
(delete-single-window))
@ -175,3 +190,6 @@
"tmux"))))
)
(provide 'em-terminal)
;;; em-terminal.el ends here

View File

@ -0,0 +1,141 @@
;;; em-version-control.el --- Module file for version control configuration.
;;
;; Copyright (C) 2017 Wojciech Kozlowski
;;
;; Author: Wojciech Kozlowski <wk@wojciechkozlowski.eu>
;; Created: 25 Aug 2017
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;; This module sets up configuration for version control packages such as
;; `magit'.
;;
;;; License: GPLv3
;;; Required packages:
;;; Code:
(defvar emodule/em-version-control-packages
'(magit
diff-hl)
)
;;; Configuration:
(defun emodule/em-version-control-init ()
"Initialise the `em-version-control' module."
;; --------------------------------------------------------------------------
;; Load and configure `magit'.
;; --------------------------------------------------------------------------
(use-package magit
:defer t
:bind
("C-x g l" . magit-log-head)
("C-x g f" . magit-log-buffer-file)
("C-x g b" . magit-blame)
("C-x g m" . magit-show-refs-popup)
("C-x g c" . magit-branch-and-checkout)
("C-x g s" . magit-status)
("C-x g r" . magit-reflog)
("C-x g t" . magit-tag)
:config
(add-hook 'magit-mode-hook 'magit-load-config-extensions)
;; unbind C-x g
(unbind-key "C-x g" magit-file-mode-map))
;; --------------------------------------------------------------------------
;; Ediff.
;; --------------------------------------------------------------------------
(defvar ediff-diff-options)
(defvar ediff-split-window-function)
(defvar ediff-window-setup-function)
(setq ediff-diff-options "-w"
ediff-split-window-function 'split-window-horizontally
ediff-window-setup-function 'ediff-setup-windows-plain)
;; --------------------------------------------------------------------------
;; Diff highlight mode.
;; --------------------------------------------------------------------------
(use-package diff-hl
:init
(global-diff-hl-mode)
(add-hook 'dired-mode-hook 'diff-hl-dired-mode)
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh))
;; --------------------------------------------------------------------------
;; Diff mode settings.
;; --------------------------------------------------------------------------
(use-package diff-mode
:init
;; Diff mode hook - whitespace mode settings and set read-only mode.
(defvar whitespace-style)
(add-hook 'diff-mode-hook (lambda ()
(setq-local whitespace-style
'(face
tabs
tab-mark
spaces
space-mark
trailing
indentation::space
indentation::tab
newline
newline-mark))
(read-only-mode 1)))
:config
(declare-function diff-find-source-location "diff-mode")
(declare-function diff-hunk-status-msg "diff-mode")
;; Extra functions ----------------------------------------------------------
;; Display source in other window whilst keeping point in the diff file.
;; Based on the code for `diff-goto-source.
(defun x-diff-display-source (&optional other-file event)
"Display the corresponding source line in another window.
`diff-jump-to-old-file' (or its opposite if the OTHER-FILE
prefix arg is given) determines whether to jump to the old
or the new file. If the prefix arg is bigger than 8 (for
example with \\[universal-argument]
\\[universal-argument]) then `diff-jump-to-old-file' is
also set, for the next invocations."
(interactive (list current-prefix-arg last-input-event))
;; When pointing at a removal line, we probably want to jump to
;; the old location, and else to the new (i.e. as if reverting).
;; This is a convenient detail when using smerge-diff.
(if event (posn-set-point (event-end event)))
(let ((rev (not (save-excursion (beginning-of-line) (looking-at "[-<]")))))
(pcase-let ((`(,buf ,line-offset ,pos ,src ,_dst ,switched)
(diff-find-source-location other-file rev)))
(let ((window (display-buffer buf t)))
(save-selected-window
(select-window window)
(goto-char (+ (car pos) (cdr src)))
(diff-hunk-status-msg line-offset (diff-xor rev switched) t))))))
;; Key-bindings -------------------------------------------------------------
;; This shadows new global key-binding for other-window.
(define-key diff-mode-map (kbd "M-o") nil)
;; This copies behaviour from other modes where C-o displays the relevant
;; (setq )ource in another window.
(define-key diff-mode-map (kbd "C-o") 'x-diff-display-source))
)
(provide 'em-version-control)
;;; em-version-control.el ends here

View File

@ -1,4 +1,4 @@
;;; workflow.el --- Module file for setting up workflows.
;;; em-workflow.el --- Module file for setting up workflows.
;;
;; Copyright (C) 2017 Wojciech Kozlowski
;;
@ -16,7 +16,9 @@
;;; Required packages:
(setq emodule/workflow-packages
;;; Code:
(defvar emodule/em-workflow-packages
'(workgroups2)
@ -24,7 +26,8 @@
;;; Configuration:
(defun emodule/workflow-init ()
(defun emodule/em-workflow-init ()
"Initialise the `em-workflow' module."
;; --------------------------------------------------------------------------
;; Enable `workgroups'.
@ -36,3 +39,6 @@
(("C-c z z" . (lambda () (interactive) (workgroups-mode)))))
)
(provide 'em-workflow)
;;; em-workflow.el ends here

View File

@ -1,126 +0,0 @@
;;; version-control.el --- Module file for version control configuration.
;;
;; Copyright (C) 2017 Wojciech Kozlowski
;;
;; Author: Wojciech Kozlowski <wk@wojciechkozlowski.eu>
;; Created: 25 Aug 2017
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;; This module sets up configuration for version control packages such as
;; `magit'.
;;
;;; License: GPLv3
;;; Required packages:
(setq emodule/version-control-packages
'(magit
diff-hl)
)
;;; Configuration:
(defun emodule/version-control-init ()
;; --------------------------------------------------------------------------
;; Load and configure `magit'.
;; --------------------------------------------------------------------------
(use-package magit
:defer t
:bind
("C-x g l" . magit-log-head)
("C-x g f" . magit-log-buffer-file)
("C-x g b" . magit-blame)
("C-x g m" . magit-show-refs-popup)
("C-x g c" . magit-branch-and-checkout)
("C-x g s" . magit-status)
("C-x g r" . magit-reflog)
("C-x g t" . magit-tag)
:config
(add-hook 'magit-mode-hook 'magit-load-config-extensions)
;; unbind C-x g
(unbind-key "C-x g" magit-file-mode-map))
;; --------------------------------------------------------------------------
;; Ediff.
;; --------------------------------------------------------------------------
(setq ediff-diff-options "-w"
ediff-split-window-function 'split-window-horizontally
ediff-window-setup-function 'ediff-setup-windows-plain)
;; --------------------------------------------------------------------------
;; Diff highlight mode.
;; --------------------------------------------------------------------------
(use-package diff-hl
:init
(global-diff-hl-mode)
(add-hook 'dired-mode-hook 'diff-hl-dired-mode)
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh))
;; --------------------------------------------------------------------------
;; Diff mode settings.
;; --------------------------------------------------------------------------
;; Diff mode hook - whitespace mode settings and set read-only mode.
(add-hook 'diff-mode-hook (lambda ()
(setq-local whitespace-style
'(face
tabs
tab-mark
spaces
space-mark
trailing
indentation::space
indentation::tab
newline
newline-mark))
(read-only-mode 1)))
;; Extra functions ----------------------------------------------------------
;; Display source in other window whilst keeping point in the diff file.
;; Based on the code for `diff-goto-source.
(defun x-diff-display-source (&optional other-file event)
"Display the corresponding source line in another window.
`diff-jump-to-old-file' (or its opposite if the OTHER-FILE
prefix arg is given) determines whether to jump to the old or
the new file. If the prefix arg is bigger than 8 (for example
with \\[universal-argument] \\[universal-argument]) then
`diff-jump-to-old-file' is also set, for the next invocations."
(interactive (list current-prefix-arg last-input-event))
;; When pointing at a removal line, we probably want to jump to
;; the old location, and else to the new (i.e. as if reverting).
;; This is a convenient detail when using smerge-diff.
(if event (posn-set-point (event-end event)))
(let ((rev (not (save-excursion (beginning-of-line) (looking-at "[-<]")))))
(pcase-let ((`(,buf ,line-offset ,pos ,src ,_dst ,switched)
(diff-find-source-location other-file rev)))
(let ((window (display-buffer buf t)))
(save-selected-window
(select-window window)
(goto-char (+ (car pos) (cdr src)))
(diff-hunk-status-msg line-offset (diff-xor rev switched) t))))))
;; Key-bindings -------------------------------------------------------------
(use-package diff-mode
:config
;; This shadows new global key-binding for other-window.
(define-key diff-mode-map (kbd "M-o") nil)
;; This copies behaviour from other modes where C-o displays the relevant
;; (setq )ource in another window.
(define-key diff-mode-map (kbd "C-o") 'x-diff-display-source))
)