From 08bb43b31a206b56069df0fafc206941947be6ec Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Fri, 10 Feb 2017 10:03:06 +0100 Subject: emacs: general fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - projectile: removed the format definition. I didn't know that the default format already took into account clashes between files from different projects. This way I don't need other packages like =uniquify=. - crux: fixed bindings. - magit: added a binding for =magit-blame= and improved the documentation. - ohers: added the =mssola-face-at-point= function Signed-off-by: Miquel Sabaté Solà --- emacs/init.html | 118 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 87 insertions(+), 31 deletions(-) (limited to 'emacs/init.html') diff --git a/emacs/init.html b/emacs/init.html index f79b590..e751911 100644 --- a/emacs/init.html +++ b/emacs/init.html @@ -4,7 +4,7 @@ mssola's GNU Emacs configuration - + @@ -425,6 +425,28 @@ I've hacked my own theme called soria<
(load-theme 'soria t)
 
+ +

+When hacking your own theme, sometimes you want to know what face is the one +that you see on the screen right now. This function from @thblt allows me to +get exactly that: +

+ +
+ +
(defun mssola-face-at-point (pos)
+  "Writes a message with the name of the face at the current point.  The POS
+  argument contains the current position of the cursor."
+
+  (interactive "d")
+
+  (let ((face (or (get-char-property (point) 'read-face-name)
+                  (get-char-property (point) 'face))))
+    (if face (message "Face: %s" face) (message "No face at %d" pos))))
+
+(global-set-key (kbd "C-c f") 'mssola-face-at-point)
+
+
@@ -790,9 +812,7 @@ Then, for keeping up with my projects I use the Projectile + Helm combination.
(use-package projectile
   :ensure t
   :config
-  (projectile-mode 1)
-  (setq projectile-mode-line
-    '(:eval (format " %s" (projectile-project-name)))))
+  (projectile-mode 1))
 
 (use-package helm
   :ensure t
@@ -1381,34 +1401,67 @@ certainly useful for some common tasks (I guess that I still need some learning)
 
(use-package magit
   :ensure t
   :config
+
+ - ; Proper initial states. - (with-eval-after-load 'evil - (add-hook 'git-commit-mode-hook 'evil-insert-state) - (evil-set-initial-state 'magit-log-edit-mode 'insert)) +

+In some cases normal mode is not the right mode (e.g. commit mode). For these +cases, set the proper default mode. +

- ; When showing the status, hide the usually-redundant "branch" section and - ; show the rest. - (add-hook 'magit-section-set-visibility-hook - '(lambda (section) - (if (string= (magit-section-type section) "branch") - 'hide - 'show))) +
- (with-eval-after-load 'evil-leader - (evil-leader/set-key "s" 'magit-status) +
(with-eval-after-load 'evil
+  (add-hook 'git-commit-mode-hook 'evil-insert-state)
+  (evil-set-initial-state 'magit-log-edit-mode 'insert))
+
+
+ +

+When showing the status, hide the usually-redundant "branch" section and show +the rest. +

- (use-package evil-magit - :ensure t - :config +
+ +
(add-hook 'magit-section-set-visibility-hook
+          '(lambda (section)
+             (if (string= (magit-section-type section) "branch")
+                 'hide
+               'show)))
+
+
+ +

+Set a key binding for magit-blame. +

+ +
+ +
(global-set-key (kbd "C-c b") 'magit-blame)
+
+
- ; The magit + evil-magit combo messes up some chords, let's fix this. - (evil-define-key 'normal magit-mode-map - "\C-h" 'evil-window-left - "\C-l" 'evil-window-right - "\C-j" 'evil-window-down - "\C-k" 'evil-window-up - "\M-p" 'helm-projectile-switch-project)))) +

+And repair some key bindings from Evil mode. +

+ +
+ +
(with-eval-after-load 'evil-leader
+  (evil-leader/set-key "s" 'magit-status)
+
+  (use-package evil-magit
+    :ensure t
+    :config
+
+    ; The magit + evil-magit combo messes up some chords, let's fix this.
+    (evil-define-key 'normal magit-mode-map
+      "\C-h" 'evil-window-left
+      "\C-l" 'evil-window-right
+      "\C-j" 'evil-window-down
+      "\C-k" 'evil-window-up
+      "\M-p"  'helm-projectile-switch-project))))
 
@@ -2605,13 +2658,16 @@ too many things into my leader and these shortcuts look sensible to me).
(use-package crux
   :ensure t
-  :bind (("C-c d" . crux-delete-file-and-buffer)
-         ("C-c r" . crux-rename-file-and-buffer)
-         ("C-c o" . crux-open-with)))
+  :config
+
+  (global-set-key (kbd "C-c d") 'crux-delete-file-and-buffer)
+  (global-set-key (kbd "C-c r") 'crux-rename-file-and-buffer)
+  (global-set-key (kbd "C-c o") 'crux-open-with))
 
+

Credits

@@ -2665,7 +2721,7 @@ along with this program. If not, see <
-- cgit v1.2.3