This files contains some global keybindings and various settings for Emacs.
:PROPERTIES: :ID: c901c3d8-a46e-4b21-9105-482ab7b8ef16 :END:
;; -*- lexical-binding: t; -*-
Apparently the new Emacs has some quirks with edebug. This fixes it.
(fset 'edebug-prin1-to-string #'prin1-to-string)
Alternatively (setq cl-print-readably t) has the same (though it affects non-edebug usage of cl-print as well).
Make all questions ask you 'y' for yes and 'n' for no instead of having to type "yes" or "no".
(fset 'yes-or-no-p 'y-or-n-p)
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
(setq-default
;; It's much easier to move around lines based on how they are displayed, rather than the actual line. This helps a ton with long
;; log file lines that may be wrapped:
line-move-visual t
visible-bell t
ring-bell-function 'ignore
;;blink-cursor-interval 0.4
;; I want to open links from org-mode in chromium
;;browse-url-browser-function (quote browse-url-chromium)
browse-url-browser-function (quote browse-url-firefox)
bookmark-default-file (expand-file-name ".bookmarks.el" user-emacs-directory)
bookmark-save-flag 1
;;original value was 30. A large number slows down emacs a bit apparently
buffers-menu-max-size 20
case-fold-search t
default-tab-width 4
;; I believe this sets up ediff to split the two windows horizontally AND to NOT show you all the commands
;; you can use on the two buffers that you are comapring
ediff-split-window-function 'split-window-horizontally
ediff-window-setup-function 'ediff-setup-windows-plain
;; When I write org-files, I like to be able to write long lines.
;; fill-column 130
;;when you are on the last line of the buffer, C-n will act like <return>
next-line-add-newlines t
indent-tabs-mode nil
inhibit-splash-screen t
inhibit-startup-echo-area-message t
inhibit-startup-message t
;;make-backup-files nil
initial-scratch-message nil
;; don't let the cursor go into minibuffer prompt
;; http://ergoemacs.org/emacs/emacs_stop_cursor_enter_prompt.html
minibuffer-prompt-properties (quote (read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt))
save-interprogram-paste-before-kill t
scroll-preserve-screen-position 'always
set-mark-command-repeat-pop t
tooltip-delay 1.5
truncate-lines nil
truncate-partial-width-windows nil)
(line-number-mode 0)
(column-number-mode 0)
I've been having weird clipboard issues with wayland. So for now, I'm doing to disable x clipboard manager and see if that helps. Basically, Emacs pauses for a long time when I quit Emacs.
(setq x-select-enable-clipboard-manager nil)
Make TAB mean indent. (global-set-key "\t" #'indent-for-tab-command)
For now I am disabling autosave and backup. This is causing issues with remote files. If I find a better way to fix this, I'll do that...but 'til then I will disable both autosave and backup files.
;;(setq auto-save-default nil)
;;(setq make-backup-files nil)
Emacs' auto-saving probably means something a little different than what you are used to. "auto save", means that Emacs will save a "backup" file for you. That way if you accidentally delete the file, you can still have a backup of the file.
Whenever, I change the buffer by 3 characters, go ahead and save the file. If Emacs is idle for 5 seconds do auto save.
I should probably try to figure out how to do enable auto-save as well. Auto save, lets you save backups of files with the filename #filename#.
I should probably try to figure out how to do enable auto-save as well. Auto save, lets you save backups of files with the filename #filename#.
:PROPERTIES: :ID: 318f52d6-8245-40ea-8958-5d78f8a053ff :END:
(defun my-find-file-root-hook ()
"Some personal preferences."
;; Turn auto save off and simplify backups (my version of tramp
;; barfs unless I do this:-)
(setq buffer-auto-save-file-name nil)
(set (make-local-variable 'backup-by-copying) nil)
(set (make-local-variable 'backup-directory-alist) '(("."))))
(add-hook 'find-file-root-hook 'my-find-file-root-hook)
(setq auto-save-file-name-transforms
`((".*" "~/.config/emacs/emacs-auto-saves/" t)))
(defun my-create-emacs-auto-saves-directory ()
(require 'f)
(when (not (f-directory? "~/.config/emacs/emacs-auto-saves"))
(f-mkdir "~/.config/emacs/emacs-auto-saves")))
(add-hook 'after-init-hook 'my-create-emacs-auto-saves-directory)
(setq auto-save-default nil
auto-save-interval 20
auto-save-time-out 5)
;; auto saving remote files is wayyy too slow...This should save some time.
(defun my-create-tramp-auto-saves-directory ()
(when (not (f-directory? "~/.config/emacs/tramp-auto-saves"))
(f-mkdir "~/.config/emacs/tramp-auto-saves")))
(add-hook 'after-init-hook 'my-create-tramp-auto-saves-directory)
;; So I am trying this method. Tramp will autosave files in a local directory.
(setq tramp-auto-save-directory "~/.config/emacs/tramp-auto-saves")
;; do not auto save remote file buffers.
;; this should work, but it does not...
;; the above solution is actually better. tramp-auto-save-directory.
;; (defun my/do-not-autosave-remote-buffers ()
;; (when (file-remote-p buffer-file-name)
;; (setq buffer-auto-save-file-name nil)))
;; (add-hook 'find-file-hook 'my/do-not-autosave-remote-buffers)
(setq auto-save-default t
auto-save-interval 20
auto-save-time-out 5)
Enable auto saving of each file that you are editing.
(auto-save-visited-mode t)
(setq auto-save-visited-interval 1)
:PROPERTIES: :ID: 096e1c0c-629d-4ee1-9e4c-16ecf2a68b2f :END: Make Emacs save backup files. And make it use a special directory for backup files. It's annoying to have to see a ton of source code files end in "~".
(setq make-backup-files t
;; make emacs save all backup~ files in this directory
backup-directory-alist '(("" . "~/.config/emacs/backups")))
(add-to-list 'backup-directory-alist
(cons tramp-file-name-regexp nil))
(add-hook 'after-init-hook 'global-display-line-numbers-mode)
(global-set-key (kbd "C-x C-k") #'delete-this-file)
(global-set-key (kbd "C-x C-r") #'rename-this-file-and-buffer)
(global-set-key (kbd "C-c .") #'xref-find-definitions)
(global-set-key (kbd "C-c C-h") #'help)
;;(global-set-key (kbd "C-c h k") #'helm-show-kill-ring)
(global-set-key (kbd "C-x f") #'helm-find-files)
;;(global-set-key (kbd "C-c h o") #'helm-occur)
;;(global-set-key (kbd "C-c h c") #'helm-calcul-expression)
;;(global-set-key (kbd "C-c h g") #'helm-grep-do-git-grep)
Transposing words and characters.
(global-set-key (kbd "C-c t") #'transpose-chars)
(global-set-key (kbd "C-c T") #'transpose-words)
Helm switch buffers
(global-set-key (kbd "C-x b") #'helm-buffers-list)
I want to defer loading init-gnus.org until I need it.
(defun my/gnus ()
"loads my gnus settings and starts gnus."
(interactive)
(org-babel-load-file "~/.config/emacs/lisp/init-gnus.org")
(gnus))
(global-set-key (kbd "C-c g") #'my/gnus)
(defun my/compose-mail ()
"loads my gnus settings and starts gnus."
(interactive)
(org-babel-load-file "~/.config/emacs/lisp/init-gnus.org")
(compose-mail nil '(("GCC" . "imap.dismail.de:Sent"))))
(global-set-key (kbd "C-x m") #'my/compose-mail)
(listp '((GCC . "imap.dismail.de:Sent")))
(global-set-key (kbd "C-x C-j") nil)
My modkey is "command" on a macbook.
(global-set-key (kbd "s-;") #'web-mode-comment-or-uncomment)
(global-set-key (kbd "s-a") #'mark-whole-buffer)
(global-set-key (kbd "s-d") #'my/downcase-word)
(global-set-key (kbd "s-g") #'magit-status)
(global-set-key (kbd "s-h") #'mark-paragraph)
;; This causes ERC to connect to the Freenode network upon hitting mod-i
(global-set-key (kbd "s-i") (lambda () (interactive)
(erc :server "irc.freenode.net" :port "6667"
:nick "jbranso")))
There is only one set of keychords that Emacs reserves for users to set themselves. That is "C-c ". These are my preferred keychords.
;; this conflicts with my command for dired. (global-unset-key (kbd "C-a")) (local-unset-key (kbd "C-a"))
All of my "C-c [letter]" commands
(global-set-key (kbd "C-c TAB") #'indent-whole-buffer)
;; when point is between two words, delete the space between them
(global-set-key (kbd "C-c \\") #'delete-horizontal-space)
(global-set-key (kbd "C-c SPC") #'just-one-space)
(global-set-key (kbd "C-c $") #'org-archive-subtree)
(with-eval-after-load 'flyspell
(define-key flyspell-mode-map (kbd "C-c $") nil))
;; some modes my default / in normal mode is NOT bound to helm-swoop, BUT I REALLY LIKE helm-swoop
(global-set-key (kbd "C-c /") #'helm-swoop)
(global-set-key (kbd "C-c C-o") #'org-open-at-point-global)
;; this is bound in init-smart-comment.el
;;(global-set-key (kbd "C-c ;") #'comment-dwim)
;;(define-key global-map (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c b") #'(lambda ()
"Switch to the previous buffer"
(interactive)
(switch-to-buffer nil)))
(global-set-key (kbd "C-c B") #'browse-kill-ring)
(global-set-key (kbd "C-c C") #'hydra-org-timer/body)
;;org-capture is SOOO helpful!!
(global-set-key (kbd "C-c c") 'org-capture)
;;open up a new dired window for the current directory
(global-set-key (kbd "C-c d") #'dired-jump)
;; find the current tag smart. Just know what I mean.
;; For example, with point on the following javascript function upcaseWord
;; var upcase = upcaseWord (string);
;; And you type C-c D, ggtags, when open the buffer where that function is defined
;;(global-set-key (kbd "C-c D") 'ggtags-find-tag-dwim)
(global-set-key (kbd "C-c D") #'dumb-jump-go)
(global-set-key (kbd "C-c e") #'helm-M-x)
(global-set-key (kbd "C-c E") #'eshell)
(global-set-key (kbd "C-c f") #'isearch-forward-regexp)
(global-set-key (kbd "C-c F") #'isearch-backward-regexp)
;; open up email mail program
(global-set-key (kbd "C-c h") #'helm-command-prefix)
(global-set-key (kbd "C-c i") #'info-display-manual)
;; type this with point at the end of an elisp expression like
;; (print 5)<point>
;; the result will be 5 printed in the minibuffer
(global-set-key (kbd "C-c l") #'eval-last-sexp)
;;this lets you store an org link from pretty much any file
;;then type C-c C-l in an org buffer and it'll put that link it
(global-set-key (kbd "C-c L") #'org-store-link)
(global-set-key (kbd "C-c I") #'org-insert-link)
(global-set-key (kbd "C-c m") #'helm-mini)
;;print the working directory in the minibuffer
;; I should make these commands copy the output of pwd into the clipboard
(global-set-key (kbd "C-c P") #'pwd)
;;(global-set-key (kbd "C-c p") #'pwd)
;;This does recursive find and replace. But I think it only works when you are in a dired buffer
(global-set-key (kbd "C-c R") #'find-name-dired)
:PROPERTIES: :ID: 1d3474a6-f122-4a06-8edc-47711d3b811a :END:
When attempting to debug a error, often the error is Soho long that I cannot read it on Emacs. It makes more sense to turn on visual line mode, so that I can read the whole line.
(add-hook 'debugger-mode-hook 'visual-line-mode)
https://thraxys.wordpress.com/2016/01/13/utf-8-in-emacs-everywhere-forever/
#+BEGIN_SRC emacs-lisp (setq locale-coding-system 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (prefer-coding-system 'utf-8) (when (display-graphic-p) (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))) #+END_SRC Diskspace is cheap and making emacs backup my files is probably a good idea maybe this will work. ;; https://www.reddit.com/r/emacs/comments/4398wl/this_is_driving_me_nuts_emacs_will_not_let_me/ ;; https://stackoverflow.com/questions/15302973/emacs-auto-save-why-are-files-not-stored-in-the-correct-folder
;; (defvar my-auto-save-folder (concat "~/.config/emacs/auto-save")) ; folder for auto-saves ;; (setq auto-save-list-file-prefix "~/.config/emacs/auto-save/.saves-") ; set prefix for auto-saves ;; (setq auto-save-file-name-transforms `((".*", my-auto-save-folder t))) ; location for all auto-save files ;; (setq tramp-auto-save-directory my-auto-save-folder) ; auto-save tramp files in local directory
(defun sanityinc/no-trailing-whitespace ()
"Turn off display of trailing whitespace in this buffer."
(setq show-trailing-whitespace nil))
But don't show trailing whitespace in SQLi, inf-ruby etc.
(dolist (hook '(special-mode-hook
eww-mode-hook
term-mode-hook
comint-mode-hook
compilation-mode-hook
twittering-mode-hook
minibuffer-setup-hook))
(add-hook hook #'sanityinc/no-trailing-whitespace))
(global-set-key (kbd "RET") #'newline-and-indent)
When you define a macro, you can type C-x Q to prompt the user for input. Very helpful and cool! #+BEGIN_SRC emacs-lisp
(defun my-macro-query (arg) "Prompt for input using minibuffer during kbd macro execution. With prefix argument, allows you to select what prompt string to use. If the input is non-empty, it is inserted at point." (interactive "P") (let* ((query (lambda () (kbd-macro-query t))) (prompt (if arg (read-from-minibuffer "PROMPT: ") "Input: ")) (input (unwind-protect (progn (add-hook 'minibuffer-setup-hook query) (read-from-minibuffer prompt)) (remove-hook 'minibuffer-setup-hook query)))) (unless (string= "" input) (insert input))))
(global-set-key "\C-xQ" #'my-macro-query) #+END_SRC
Make emacs completetion better #+BEGIN_SRC emacs-lisp (setq read-file-name-completion-ignore-case t) (setq read-buffer-completion-ignore-case t) #+END_SRC
add to the list of file names NOT to complete
(mapc (lambda (x)
(add-to-list 'completion-ignored-extensions x))
'(".aux" ".bbl" ".blg" ".exe"
".log" ".meta" ".out"
".synctex.gz" ".tdo" ".toc"
"-pkg.el" "-autoloads.el"
"Notes.bib" "auto/"))
This may not be necessary anymore. Emacs is saving all my files automatically.
TODO FIX ME, this is now causing errors?
(defun my/save-all-buffers ()
(interactive)
(save-some-buffers t))
(add-hook 'after-save-hook 'my/save-all-buffers)
(remove-hook 'after-save-hook' my/save-all-buffers)
If a file has changed on disk, then automatically revert the buffer and don't complain about it
(global-auto-revert-mode 1)
Be quiet about reverting files.
(setq auto-revert-verbose nil)
This apparently also updates dired buffers too.
(setq global-auto-revert-non-file-buffers t)
Sometimes I want to edit a file like /etc/nginx/nginx.conf.
This file is owned by root. So when Emacs visits the buffer, I can't edit or save the file. To fix this problem, I have to open the file via tramp like this: "/sudo:root@parabola:/etc/nginx/nginx.conf" or "/sudo::/etc/nginx/nginx.conf".
BUT I want Emacs to check to see if a file is writeable, if it is, then open that file as root. I can do this by using the find-file-hook!
(defun my/find-file-hook ()
;; when I can't write the file, open this file as root instead.
(when (not (file-writable-p buffer-file-name))
;; If this file is located on the remote linode machine,
(if (s-contains? "69.164.207.104" buffer-file-name)
;; If this is on the remote machine filename looks like /ssh:joshua@REMOTE:/path/to/file
;; I just need to replace "joshua" with "root"
(find-alternate-file (s-replace "joshua" "root" buffer-file-name))
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name)))))
(add-hook 'find-file-hook 'my/find-file-hook)
(put 'narrow-to-region 'disabled nil) (put 'narrow-to-page 'disabled nil) (put 'narrow-to-defun 'disabled nil)
Also the default narrow commands suck. Narrow-dwim is super awesome!
http://endlessparentheses.com/emacs-narrow-or-widen-dwim.html
(defun narrow-or-widen-dwim (p)
"Widen if buffer is narrowed, narrow-dwim otherwise.
Dwim means: region, org-src-block, org-subtree, or defun,
whichever applies first. Narrowing to org-src-block actually
calls `org-edit-src-code'.
With prefix P, don't widen, just narrow even if buffer is
already narrowed."
(interactive "P")
(declare (interactive-only))
(cond ((and (buffer-narrowed-p) (not p)) (widen))
((region-active-p)
(narrow-to-region (region-beginning) (region-end)))
((derived-mode-p 'org-mode)
;; `org-edit-src-code' is not a real narrowing
;; command. Remove this first conditional if you
;; don't want it.
(cond ((ignore-errors (org-edit-src-code))
(delete-other-windows))
((ignore-errors (org-narrow-to-block) t))
(t (org-narrow-to-subtree))))
((derived-mode-p 'latex-mode)
(LaTeX-narrow-to-environment))
(t (narrow-to-defun))))
;; This line actually replaces Emacs' entire narrowing
;; keymap, that's how much I like this command. Only copy it
;; if that's what you want.
(define-key ctl-x-map "n" #'narrow-or-widen-dwim)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
Delete any trailing whitespace before save.
(defun my/delete-trailing-whitespace ()
"This is just a defined function that deletes trailing whitespace"
(interactive)
(when
;; don't delete white space in my programming dirs
;; where I may commit these changes to other projects.
(and
(not (s-match ".*prog/guix.*" (buffer-file-name)))
(not (s-match ".*prog/c.*" (buffer-file-name)))
(not (s-match ".*prog/gnu.*" (buffer-file-name)))
(not (s-match ".*prog/web.*" (buffer-file-name))))
(delete-trailing-whitespace)))
(defun my/leave-trailing-whitespace-hook ()
"This defun leaves trailing whitespace"
(interactive)
(remove-hook 'before-save-hook 'my/delete-trailing-whitespace))
(defun my/delete-trailing-whitespace-hook ()
"This defun leaves trailing whitespace"
(interactive)
(add-hook 'before-save-hook 'my/delete-trailing-whitespace))
(my/delete-trailing-whitespace-hook)
Make the lines in the buffer wrap around the edges of the screen. YES!!!!! These next two modes auto-indents org-buffers as you type! NO NEED FOR to press C-c q or fill-paragraph ever again!
snaheu snth antuh ah asntuh ntaeo husnth eosntuh antu hsntea husntahu l.,rc santhu sntahu src., husanthusant husntah usnat hsnate hsantu hsantuh seoantua ou santhue sntahue stnhe snato sntao sntoae husntaoh usaneotu h snth santue hstao hsnth sntaho snt hsnta usnth sntheoa usnt hsntoh s4cu hsnta husnatu ehs anteh asnteouh snta hunth usntha unsto utneo untse hsntea husna hulrc,' huasnthu snato hulcr., husnteahu snahu sanhu snatu hasnu l.,rcuh ansethu aontu hrc, huasu hsante neou
(defun my/auto-call-fill-paragraph-for-org-mode ()
"Call two modes to automatically call fill-paragraph for you."
(visual-line-mode)
;;(org-indent-mode)
)
(add-hook 'org-mode-hook 'my/auto-call-fill-paragraph-for-org-mode)
(defun my/auto-fill-mode-and-aggressive-fill-paragraph ()
"Turn on auto-fill-mode and aggressive-fill-paragraph. These
two modes working together will enable you to add text in the
middle of a paragraph, and Emacs will
[[info:emacs#Filling][info:emacs#Filling]] auto-fill the
paragraph for you."
(auto-fill-mode)
(aggressive-fill-paragraph-mode))
;; aggressive fill paragraph mode does not work for many many many
;; major-modes. (dolist (hook '(org-mode-hook prog-mode-hook
;; text-mode-hook)) (add-hook hook
;; 'my/auto-fill-mode-and-aggressive-fill-paragraph))
(defun indent-whole-buffer ()
"This indents the whole buffer"
(interactive)
(indent-region (point-min) (point-max)))
the default behavior on i-search stinks. This is a lot better http://endlessparentheses.com/better-backspace-during-isearch.html?source=rss
(defun mydelete ()
"Delete the failed portion of the search string, or the last char if successful."
(interactive)
(with-isearch-suspended
(setq isearch-new-string
(substring
isearch-string 0 (or (isearch-fail-pos) (1- (length isearch-string))))
isearch-new-message
(mapconcat 'isearch-text-char-description isearch-new-string ""))))
(define-key isearch-mode-map (kbd "DEL") 'mydelete)
http://endlessparentheses.com/ispell-and-abbrev-the-perfect-auto-correct.html I am not a fantastic typist. My speed is acceptable, but I make a great deal of mistakes. The following snippet has turned me into the Messi of keyboards.
Whenever I make a typo:
Hit C-x C-i, instead of erasing the mistake; Select the appropriate correction (thanks to Ispell); Sleep easier at night knowing I'll never see that mistake again (thanks to abbrev).
(define-key ctl-x-map "\C-i" #'endless/ispell-word-then-abbrev)
(global-set-key (kbd "C-c $") #'endless/ispell-word-then-abbrev)
(defun endless/ispell-word-then-abbrev (p)
"Call `ispell-word', then create an abbrev for it.
With prefix P, create local abbrev. Otherwise it will
be global."
(interactive "P")
(let (bef aft)
(save-excursion
(while (progn
(backward-word)
(and (setq bef (thing-at-point 'word))
(not (ispell-word nil 'quiet)))))
(setq aft (thing-at-point 'word)))
(when (and aft bef (not (equal aft bef)))
(setq aft (downcase aft))
(setq bef (downcase bef))
(define-abbrev
(if p local-abbrev-table global-abbrev-table)
bef aft)
(message "\"%s\" now expands to \"%s\" %sally"
bef aft (if p "loc" "glob")))))
(setq save-abbrevs 'silently)
(setq-default abbrev-mode t)
This command is awesome! It'll let you transform stuff like:
var 5 = 10; var this = 20; var howIMetYourMother = 29;
var 5 = 10; var this = 20; var howIMetYourMother = 29;
By just pressing C-c x RET = RET #+BEGIN_SRC emacs-lisp (global-set-key (kbd "C-c x") #'align-regexp) #+END_SRC
;;snumber of lines you are on. nlinum is much better than linum mode. ;; de make emacs really SLOW when your files get to be past 1000 lines long ;; s faster than linum mode, BUT it will not let me open a new frame ;; kage nlinum ;; e t ;; (global-nlinum-mode 1)) ;; hlights search and replacements as you type VERY helpful for dired-do-replace-regexp and isearch-regexp
;; ntic is supposed to have that feature too. ;;T highlights the current word under point! very cool! ;; e-package 'highlight-symbol) ;; (hook '(prog-mode-hook html-mode-hook css-mode-hook)) ;; ook hook 'highlight-symbol-mode) ;; k hook 'highlight-symbol-nav-mode)) ;; ter-load 'highlight-symbol
;;-------------------------------------------------------------------- ;; egion ;;-------------------------------------------------------------------- ;; ing for this is listed below ;; s not play well with evil ;; rarely use it, let's not include it ;; kage expand-region)
(global-set-key (kbd "C-c s") #'helm-do-grep-ag)
This is the sx.el program, which lets your read, comment, or write stack overflow questions, which is a popular hacking hele.
(global-set-key (kbd "C-c S") #'sx-search)
Mulrsors, which does not work well with evil mode. switch to emacs state to use these commands (use-package multiple-cursors ) (gl-key (kbd "C-c <") #'mc/mark-previous-like-this) ; (gl-key (kbd "C-c >") #'mc/mark-next-like-this) (gl-key (kbd "C-c C-<") #'mc/mark-all-like-this) ;; ive region to multiple cursors: ;;(et-key (kbd "C-c c c") #'mc/edit-lines) ;;(et-key (kbd "C-c c e") #'mc/edit-ends-of-lines) ;;(et-key (kbd "C-c c a") #'mc/edit-beginnings-of-lines)
;; myself use C-w h/t/n/s when changing to other windows (gl-key (kbd "C-x o") 'other-window) ;; elf use "s-s" (glet-key (kbd "C-x C-s")) ;;---------------------------------------------------------------------------- ;; Fix backward-up-list to understand quotes, see http://bit.ly/h7mdIL ;;---------------------------------------------------------------------------- (defun backward-up-sexp (arg) "Jump up to the start of the ARG'th enclosing sexp." (interactive "p") (let ((ppss (syntax-ppss))) (cond ((elt ppss 3) (goto-char (elt ppss 8)) (backward-up-sexp (1- arg))) ((backward-up-list arg)))))
(global-set-key [remap backward-up-list] 'backward-up-sexp) ; C-M-u, C-M-up
(defhydra hydra-rectangle (:body-pre (rectangle-mark-mode 1)
:color pink
:post (deactivate-mark))
"
^_t_^ _d_elete str_i_ng
_n_ _s_ _o_k _y_ank
^_h_^ _n_ew-copy _r_eset
^^^^ _e_xchange _u_ndo
^^^^ ^ ^ _p_aste
"
("n" backward-char nil)
("s" forward-char nil)
("t" previous-line nil)
("h" next-line nil)
("e" exchange-point-and-mark nil)
("k" copy-rectangle-as-kill nil)
("d" delete-rectangle nil)
("r" (if (region-active-p)
(deactivate-mark)
(rectangle-mark-mode 1)) nil)
("y" yank-rectangle nil)
("u" undo nil)
("i" string-rectangle nil)
("p" kill-rectangle nil)
("o" nil nil))
(global-set-key (kbd "C-x SPC") 'hydra-rectangle/body)
This is a cool feature, but I can't find a convenient binding for it. This would be great for a hydra.
Shift lines up and down with M-up and M-down. When paredit is enabled, it will use those keybindings. For this reason, you might prefer to use M-S-up and M-S-down, which will work even in lisp modes.
(use-package move-dup )
(global-set-key (kbd "M-t") #'md/move-lines-up)
(define-key evil-normal-state-map (kbd "C-s-t") 'md/move-lines-up)
;; this won't work because this is a command that feeds into awesome
(global-set-key (kbd "M-h") #'md/move-lines-down)
(global-set-key (kbd "M-p") 'md/duplicate-down)
(global-set-key (kbd "M-P") 'md/duplicate-up)
Start the emacs server for use via org-protocal.
(require 'server)
(when (not (server-running-p))
(server-start))
(provide 'init-editing-utils)