Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
init.el excerpt
(defun quick-copy-line ()
"Copy the whole line that point is on and move to the beginning of the next line.
Consecutive calls to this command append each line to the
kill-ring."
(interactive)
(let ((beg (line-beginning-position 1))
(end (line-beginning-position 2)))
(if (eq last-command 'quick-copy-line)
(kill-append (buffer-substring beg end) (< end beg))
(kill-new (buffer-substring beg end))))
(beginning-of-line 2))
(defun quick-cut-line ()
"Cut the whole line that point is on. Consecutive calls to this command append each line to the kill-ring."
(interactive)
(let ((beg (line-beginning-position 1))
(end (line-beginning-position 2)))
(if (eq last-command 'quick-cut-line)
(kill-append (buffer-substring beg end) (< end beg))
(kill-new (buffer-substring beg end)))
(delete-region beg end))
(beginning-of-line 1)
(setq this-command 'quick-cut-line))
(transient-mark-mode 1)
(defun select-current-line ()
"Select the current line"
(interactive)
(end-of-line) ; move to end of line
(set-mark (line-beginning-position)))
(define-key help-map "d" 'docsetutil-search) ; C-h d
(defvar th-shell-popup-buffer nil)
(defun th-shell-popup ()
"Toggle a shell popup buffer with the current file's directory as cwd."
(interactive)
(unless (buffer-live-p th-shell-popup-buffer)
(save-window-excursion (shell "*Popup Shell*"))
(setq th-shell-popup-buffer (get-buffer "*Popup Shell*")))
(let ((win (get-buffer-window th-shell-popup-buffer))
(dir (file-name-directory (or (buffer-file-name)
;; dired
dired-directory
;; use HOME
"~/"))))
(if win
(quit-window nil win)
(pop-to-buffer th-shell-popup-buffer nil t)
(comint-send-string nil (concat "cd " dir "\n")))))
(global-set-key (kbd "C-M-S-s-l") 'select-current-line)
(global-set-key (kbd "C-M-S-s-f") 'hippie-expand)
(global-set-key (kbd "C-M-s-#") 'comment-or-uncomment-region)
(global-set-key (kbd "C-M-S-s-<left>") 'delete-window)
(global-set-key (kbd "C-M-S-s-<SPC>") 'th-shell-popup)
(global-set-key (kbd "C-M-S-s-p") 'switch-to-prev-buffer)
(global-set-key (kbd "C-M-S-s-n") 'switch-to-next-buffer)
(global-set-key (kbd "C-M-S-s-v") 'insert-register)
(global-set-key (kbd "C-M-S-s-c") 'copy-to-register)
(global-set-key (kbd "C-M-S-s-e") 'eval-buffer)
(global-set-key (kbd "C-M-S-s-<right>") 'split-window-right)
(global-set-key (kbd "C-M-S-s-<down>") 'split-window-below)
(global-set-key (kbd "C-M-S-s-<backspace>") 'kill-this-buffer)
(global-set-key (kbd "C-M-S-s-w") 'quick-copy-line)
(global-set-key (kbd "C-M-S-s-k") 'quick-cut-line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment