2020-12-07 21:09:35 +00:00
|
|
|
(defun copy-whole-line ()
|
|
|
|
(interactive)
|
|
|
|
(save-excursion
|
|
|
|
(kill-new
|
|
|
|
(buffer-substring
|
|
|
|
(point-at-bol)
|
|
|
|
(point-at-eol)))))
|
2021-02-23 11:46:16 +00:00
|
|
|
(global-set-key (kbd "C-c w l") 'copy-whole-line)
|
2020-12-07 21:09:35 +00:00
|
|
|
|
|
|
|
(defun kill-all-buffers ()
|
|
|
|
(interactive)
|
|
|
|
(mapc 'kill-buffer (buffer-list)))
|
|
|
|
(global-set-key (kbd "C-c k k") 'kill-all-buffers)
|
2020-12-20 21:07:30 +00:00
|
|
|
|
2020-12-30 00:08:12 +00:00
|
|
|
(defun split-and-follow-horizontally ()
|
|
|
|
(interactive)
|
|
|
|
(split-window-below)
|
|
|
|
(balance-windows)
|
|
|
|
(other-window 1))
|
|
|
|
(global-set-key (kbd "C-x 2") 'split-and-follow-horizontally)
|
|
|
|
|
|
|
|
(defun split-and-follow-vertically ()
|
|
|
|
(interactive)
|
|
|
|
(split-window-right)
|
|
|
|
(balance-windows)
|
|
|
|
(other-window 1))
|
|
|
|
(global-set-key (kbd "C-x 3") 'split-and-follow-vertically)
|
|
|
|
|
2021-02-23 11:46:16 +00:00
|
|
|
(defun switch-to-previous-buffer ()
|
|
|
|
(interactive)
|
|
|
|
(switch-to-buffer (other-buffer (current-buffer) 1)))
|
|
|
|
(global-set-key (kbd "C-x b") 'switch-to-previous-buffer)
|
|
|
|
(global-set-key (kbd "C-c b") 'switch-to-buffer)
|
|
|
|
|
2020-12-20 21:07:30 +00:00
|
|
|
;; compilation
|
|
|
|
(setq compile-command "make ")
|
2021-02-23 11:46:16 +00:00
|
|
|
(global-set-key (kbd "C-x C-m") 'compile)
|
|
|
|
|
2021-04-28 18:08:51 +00:00
|
|
|
(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)))
|
|
|
|
|
|
|
|
|
2021-02-23 11:46:16 +00:00
|
|
|
(defun mark-line ()
|
|
|
|
(interactive)
|
|
|
|
(move-beginning-of-line nil)
|
|
|
|
(set-mark (point))
|
|
|
|
(move-end-of-line nil))
|
|
|
|
|
2021-04-28 18:08:51 +00:00
|
|
|
(global-unset-key (kbd "C-x C-z")) ; disable suspend frame
|
2021-03-17 11:51:55 +00:00
|
|
|
(global-set-key (kbd "C-x C-z") 'mark-line)
|
2021-02-23 11:46:16 +00:00
|
|
|
(global-unset-key (kbd "C-z")) ; disable suspend frame
|
2021-03-17 11:51:55 +00:00
|
|
|
(global-set-key (kbd "C-x C-x") 'other-window)
|
|
|
|
(global-set-key (kbd "C-x C-b") '(lambda () (interactive)
|
|
|
|
(bs-show nil)
|
|
|
|
(swiper)))
|
|
|
|
|
|
|
|
(defun toggle-indent ()
|
|
|
|
(interactive)
|
|
|
|
(setq-default indent-tabs-mode (not indent-tabs-mode)))
|
2021-04-09 15:56:51 +00:00
|
|
|
|
|
|
|
(global-set-key [f5] (lambda ()
|
|
|
|
(interactive)
|
|
|
|
(disable-theme 'basic)
|
|
|
|
(load-theme 'magik)))
|
|
|
|
(global-set-key [f6] (lambda ()
|
|
|
|
(interactive)
|
|
|
|
(disable-theme 'magik)
|
|
|
|
(load-theme 'basic)))
|
2021-04-28 18:08:51 +00:00
|
|
|
|
|
|
|
(defun current-line-empty-p ()
|
|
|
|
(save-excursion
|
|
|
|
(beginning-of-line)
|
|
|
|
(looking-at-p "[[:space:]]*$")))
|
|
|
|
|
|
|
|
(defun 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)
|
|
|
|
(when (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))
|