89 lines
2.8 KiB
EmacsLisp
89 lines
2.8 KiB
EmacsLisp
;;; Compilation
|
|
(setq compile-command "make ")
|
|
;; C-m functions as \r, so pressing C-x C-m C-m will call compile and skip the prompt.
|
|
(global-set-key (kbd "C-x C-m") 'compile)
|
|
|
|
;; Nicer movement in compilation-mode.
|
|
(add-hook 'compilation-mode-hook
|
|
(lambda () (local-set-key (kbd "n") 'compilation-next-error)))
|
|
(add-hook 'compilation-mode-hook
|
|
(lambda () (local-set-key (kbd "p") 'compilation-previous-error)))
|
|
|
|
;; Function for selecting the current line.
|
|
(defun fez/mark-line ()
|
|
"Selects the current line with the mark."
|
|
(interactive)
|
|
(move-beginning-of-line nil)
|
|
(set-mark (point))
|
|
(move-end-of-line nil))
|
|
|
|
;; Toggle between indenting with tabs or spaces.
|
|
(defun fez/toggle-indent ()
|
|
(interactive)
|
|
(setq-default indent-tabs-mode (not indent-tabs-mode)))
|
|
|
|
(defun fez/current-line-empty-p ()
|
|
(save-excursion
|
|
(beginning-of-line)
|
|
(looking-at-p "[[:space:]]*$")))
|
|
|
|
(defun fez/flash-region (&optional timeout)
|
|
"Temporarily highlight region from START to END. Taken from SLIME source code and modified."
|
|
(interactive)
|
|
(transient-mark-mode)
|
|
(save-excursion
|
|
(mark-defun)
|
|
;; Don't mark the line above the s-expression.
|
|
(while (fez/current-line-empty-p)
|
|
(forward-char))
|
|
(let* ((start (region-beginning))
|
|
(end (region-end))
|
|
(overlay (make-overlay start end)))
|
|
(deactivate-mark)
|
|
(overlay-put overlay 'face 'secondary-selection)
|
|
(run-with-timer (or timeout 0.2) nil 'delete-overlay overlay)))
|
|
(transient-mark-mode))
|
|
|
|
(defun fez/insert-keybind ()
|
|
(interactive)
|
|
(insert (concat "(kbd \""
|
|
(key-description (read-key-sequence-vector "Key sequence: "))
|
|
"\")")))
|
|
|
|
(defun fez/time-stamp ()
|
|
(interactive)
|
|
(shell-command "LANG=nb_NO.UTF-8 date +%d-%m-%Y" t))
|
|
|
|
;; Eshell convinience commands.
|
|
(defalias 'open 'find-file-other-window)
|
|
(defalias 'clean 'eshell/clear-scrollback)
|
|
|
|
;;; Keybinds
|
|
|
|
;; C-x C-z and C-z are normally mapped to suspend-frame, an absolutely useless function.
|
|
;; Unbind them before making the keybind useful.
|
|
(global-unset-key (kbd "C-x C-z"))
|
|
(global-unset-key (kbd "C-z"))
|
|
(global-set-key (kbd "C-x C-z") 'fez/mark-line)
|
|
|
|
;; Better buffer management (smol).
|
|
(global-set-key (kbd "C-x C-b") 'bs-show)
|
|
|
|
;; Insipiration from Nyxt, kill the current buffer.
|
|
(global-set-key (kbd "C-x C-k") 'kill-this-buffer)
|
|
|
|
(global-set-key (kbd "C-c t") 'fez/time-stamp)
|
|
|
|
;; Binds for switching between light and dark themes.
|
|
(global-set-key [f5] (lambda ()
|
|
(interactive)
|
|
(disable-theme 'basic)
|
|
(load-theme 'magik)))
|
|
(global-set-key [f6] (lambda ()
|
|
(interactive)
|
|
(disable-theme 'magik)
|
|
(load-theme 'basic)))
|
|
|
|
(add-hook 'emacs-lisp-mode-hook
|
|
(lambda () (local-set-key (kbd "C-c k") #'fez/insert-keybind)))
|