diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2019-12-07 14:47:05 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2019-12-07 14:47:05 +0100 |
| commit | 507426a6c981cf64529687f70b91bb005a112572 (patch) | |
| tree | 1d3629c414b402ecddb64bed721a61d5e4b39d1c /.emacs | |
| parent | 372dd853ac4052b472a7f5a285c6fdf898bd20b7 (diff) | |
| download | dotfiles-507426a6c981cf64529687f70b91bb005a112572.tar.xz | |
Move commands use for keybindings around
I'm about to add another my/make-… function, and it will need to be
defined before those global-set-key calls.
Diffstat (limited to '.emacs')
| -rw-r--r-- | .emacs | 80 |
1 files changed, 40 insertions, 40 deletions
@@ -58,6 +58,8 @@ ;; Pictograms '("/!\\" ?⚠))) +;; C-c [[:alpha:]] is reserved for users - let's make good use of it. + (defun my/make-toggle-input-method (input-method) (lambda () (:documentation (format "Toggle `%s' input method." input-method)) @@ -68,7 +70,36 @@ (deactivate-input-method) (set-input-method input-method t)))) -;; C-c [[:alpha:]] is reserved for users - let's make good use of it. +(defun my/set-tab-width (&optional arg) + (interactive "P") + (let ((new-width (cond (arg (prefix-numeric-value arg)) + ((= tab-width 4) 8) + (4))) + (old-width tab-width)) + ;; TODO: for some reason, set-variable takes effect immediately, + ;; but setq(-local)? do not: I need to move the cursor before tabs + ;; are re-drawn. + (set-variable 'tab-width new-width) + (message "changed from %s to %s" old-width new-width))) + +(defun my/kill-ring-filename () + (interactive) + (kill-new (or (buffer-file-name) default-directory))) + +(defun my/kill-ring-pipe-region (command) + (interactive (list (read-shell-command "Shell command on region: "))) + (let ((input (funcall region-extract-function nil))) + (with-temp-buffer + (insert input) + (call-process-region (point-min) (point-max) shell-file-name + t t nil shell-command-switch command) + (kill-new (buffer-string))))) + +(defun my/kill-ring-shell (command) + (interactive (list (read-shell-command "Shell command: "))) + (with-temp-buffer + (call-process-shell-command command nil t) + (kill-new (buffer-string)))) (global-set-key (kbd "C-c c") 'compile) (global-set-key (kbd "C-c e f") 'auto-fill-mode) @@ -177,6 +208,14 @@ (add-to-list 'compilation-finish-functions 'my/compilation-notify) +(defun my/make-tabless (f) + "Make a function which will run F with `indent-tabs-mode' disabled." + (lambda () + (:documentation (format "Run `%s' with `indent-tabs-mode' set to nil." f)) + (interactive) + (let ((indent-tabs-mode nil)) + (call-interactively f)))) + (defun my/makefile-hook () ;; I would rather align backslashes with spaces rather than tabs; ;; however, I would also like indent-tabs-mode to remain non-nil. @@ -251,45 +290,6 @@ ;; Helper functions and miscellaneous settings. -(defun my/make-tabless (f) - "Make a function which will run F with `indent-tabs-mode' disabled." - (lambda () - (:documentation (format "Run `%s' with `indent-tabs-mode' set to nil." f)) - (interactive) - (let ((indent-tabs-mode nil)) - (call-interactively f)))) - -(defun my/set-tab-width (&optional arg) - (interactive "P") - (let ((new-width (cond (arg (prefix-numeric-value arg)) - ((= tab-width 4) 8) - (4))) - (old-width tab-width)) - ;; TODO: for some reason, set-variable takes effect immediately, - ;; but setq(-local)? do not: I need to move the cursor before tabs - ;; are re-drawn. - (set-variable 'tab-width new-width) - (message "changed from %s to %s" old-width new-width))) - -(defun my/kill-ring-filename () - (interactive) - (kill-new (or (buffer-file-name) default-directory))) - -(defun my/kill-ring-pipe-region (command) - (interactive (list (read-shell-command "Shell command on region: "))) - (let ((input (funcall region-extract-function nil))) - (with-temp-buffer - (insert input) - (call-process-region (point-min) (point-max) shell-file-name - t t nil shell-command-switch command) - (kill-new (buffer-string))))) - -(defun my/kill-ring-shell (command) - (interactive (list (read-shell-command "Shell command: "))) - (with-temp-buffer - (call-process-shell-command command nil t) - (kill-new (buffer-string)))) - (defun my/froggify () (ispell-change-dictionary "fr") (setq-local colon-double-space nil) |
