Page 18 of 23
Re: Emacs tips and tricks
Posted: Thu Apr 07, 2016 10:31 pm
by kondor
@DrChroot:
I'm really grooving to Spacemacs, too. :) Since I hafta use vi/vim a lot anyway, evilmode is kind of a no-brainer. But if you're coming from years of vanilla emacs bindings, the evil-centric philosophy is obvious heresy. Also, the layer based configuration is different enough that it's probly gonna rustle some jimmies.
After a couple of emacs bankruptcies, though, layered configurations are exactly what I wanted out of emacs. I think the whole architecture jibes quite well with what John Wiegley is doing with the future of emacs as a platform -- discussed here:
http://sachachua.com/blog/2015/12/2015- ... -can-help/
Re: Emacs tips and tricks
Posted: Fri Apr 08, 2016 5:51 pm
by franksinistra
Recently i switched from mingus (due to random glitches and bug) to simple-mpc
https://github.com/jorenvo/simple-mpc
made it look cool too, a la dmenu slash mpc (using hydra), you know i'm a bit too obsessed about colors and uniformed-look
Code: Select all
(use-package simple-mpc
:config
(progn
(defun my-simple-mpc/state ()
(propertize "" 'face '(:foreground "#b262af")))
(defun my-simple-mpc/title (offset)
(let* ((idx (simple-mpc-get-current-playlist-position))
(pos (+ idx offset))
(songs (split-string (shell-command-to-string "mpc playlist") "\n"))
(title (when (> pos 0) (nth-value (1- pos) songs))))
(propertize (or title "") 'face (when (/= offset 0) '(:foreground "#868dd9")))))
(defhydra hydra-simple-mpc
(:body-pre (setq hydra-is-helpful t)
:post (setq hydra-is-helpful nil)
:hint nil
:color amaranth)
(concat "\n"
"%s(my-simple-mpc/title -1)" "\n"
" %s(my-simple-mpc/state) %s(my-simple-mpc/title 0)" "\n"
"%s(my-simple-mpc/title 1)" "\n")
("<down>" simple-mpc-next)
("<up>" simple-mpc-prev)
("<left>" simple-mpc-seek-backward)
("<right>" simple-mpc-seek-forward)
;; this is the default simple-mpc keybind
("c" simple-mpc-view-current-playlist :color blue)
("s" simple-mpc-query :color blue)
("t" simple-mpc-toggle)
("SPC" simple-mpc-toggle :color blue)
("q" nil :color blue))
)))
Re: Emacs tips and tricks
Posted: Sat Apr 09, 2016 9:04 am
by GekkoP
^ Interesting stuff. By the way, I've come the really appreciate hydra. Been using it for multiple cursors, yasnippets and smartparens.
Re: Emacs tips and tricks
Posted: Sat Apr 09, 2016 9:47 am
by franksinistra
^ hydra is very cool, although i'm only scratching the surface now... i need to investigate more, thanks GP!
Re: Emacs tips and tricks
Posted: Sat Apr 09, 2016 9:51 am
by GekkoP
^ np. For instance:
Code: Select all
(use-package multiple-cursors ; Easily place multiple cursors in a buffer
:ensure t
:bind ("C-c o" . mu-multiple-cursors/body)
:init
(defhydra mu-multiple-cursors (:hint nil)
"
Multiple cursors (quit with _q_)
^Mark^ ^Edit^ ^Other^
^----^----------------^----^--------------^-----^----------------------
_e_: mark more _l_: edit lines _a_: vertical align
_h_: mark all _C-a_: edit begs _s_: set rect action
_n_: mark next _C-e_: edit ends
_p_: mark previous
_r_: mark regexp
_C-s_: mark region
"
("q" nil)
("a" mc/vertical-align :exit t)
("e" mc/mark-more-like-this-extended)
("h" mc/mark-all-like-this-dwim)
("l" mc/edit-lines :exit t)
("n" mc/mark-next-like-this)
("p" mc/mark-previous-like-this)
("r" vr/mc-mark)
("s" set-rectangular-region-anchor)
("C-a" mc/edit-beginnings-of-lines :exit t)
("C-e" mc/edit-ends-of-lines :exit t)
("C-s" mc/mark-all-in-region))
:config
(setq mc/mode-line
;; Simplify the MC mode line indicator
'(:propertize (:eval (concat " " (number-to-string
(mc/num-cursors))))
face font-lock-warning-face)))
Re: Emacs tips and tricks
Posted: Sat Apr 30, 2016 6:28 pm
by slartie
Perhaps you're new to Emacs, or you find the keybindings a forbidding place that keeps you from ever diving in. There's help at your fingertips. Apart from going through the Emacs Tutorial ("C-h t" which means press and hold down the CTRL key and pressing h, releasing the key and pressing t), GNU also offers a handy cheat sheet.
https://www.gnu.org/software/emacs/refc ... efcard.pdf
If you find the GNU Emacs cheat sheet to be a bit too dry for your tastes, you might enjoy the wonderful Sacha Chua's creative illustration series.
http://sachachua.com/blog/series/a-visu ... -to-emacs/
I did a, for me at least, thorough search on the forums and couldn't find any mention of these two links, so I decided to throw them in here. Sacha's illustrations have a few years on them now, but in Emacs terms it's basically brand new.
Re: Emacs tips and tricks
Posted: Sun May 01, 2016 8:25 am
by GekkoP
^ That's some awesome stuff. I've been using
which-key for a while, now, and that can also be helpful for beginners.
Re: Emacs tips and tricks
Posted: Sun May 01, 2016 9:11 am
by slartie
which-key is so damned useful - beginner or otherwise.
Re: Emacs tips and tricks
Posted: Tue May 03, 2016 4:03 pm
by GekkoP
Disabling mouse only in Emacs:
http://endlessparentheses.com/disable-m ... emacs.html
I prefer disabling only the touchpad though, so, inspired by the comments in that blog post, I came up with this:
Code: Select all
(defun mu-touchpad-off ()
"Disable touchpad using an external shell script.
It needs https://github.com/manuel-uberti/scripts/blob/master/touchpad-off
in `exec-path'.
Examples:
(add-hook 'focus-in-hook #'mu-touchpad-off)"
(interactive)
(let ((toff (executable-find "touchpad-off")))
(unless toff
(user-error "Shell script touchpad-off not found"))
(with-temp-buffer
(shell-command toff t))))
(defun mu-touchpad-on ()
"Enable touchpad using an external shell script.
It needs https://github.com/manuel-uberti/scripts/blob/master/touchpad-on
in `exec-path'.
Examples:
(add-hook 'focus-out-hook #'mu-touchpad-on)
(add-hook 'delete-frame-functions #'mu-touchpad-on)"
(interactive)
(let ((ton (executable-find "touchpad-on")))
(unless ton
(user-error "Shell script touchpad-on not found"))
(with-temp-buffer
(shell-command ton t))))
Re: Emacs tips and tricks
Posted: Mon May 09, 2016 7:19 pm
by GekkoP
Better flyspell interface, completion-read agnostic:
https://github.com/d12frosted/flyspell-correct
Re: Emacs tips and tricks
Posted: Wed Jun 01, 2016 11:10 am
by GekkoP
If your killing spree is too much to tame, you might find this useful.
Code: Select all
(defun mu-reopen-last-killed-buffer ()
"Quickly reopen last killed buffer."
(interactive)
(find-file (car recentf-list)))
Re: Emacs tips and tricks
Posted: Fri Jun 03, 2016 1:12 pm
by slartie
Smartparens is cool and all, but I don't want everything paired eeeeverywhere. In lisp dialects, the ' character usually stands alone, so let's stop pairing that one.
Code: Select all
(with-eval-after-load 'smartparens
(sp-local-pair 'emacs-lisp-mode "'" nil :actions nil)
(sp-local-pair 'lisp-interaction-mode "'" nil :actions nil)
(sp-local-pair 'scheme-mode "'" nil :actions nil)
(sp-local-pair 'inferior-scheme-mode "'" nil :actions nil))
Re: Emacs tips and tricks
Posted: Fri Jun 03, 2016 4:42 pm
by GekkoP
^ Weird, I did nothing and Smartparens is not automatically pairing the quote in my case. Althout I have this in my config:
Code: Select all
(dolist (hook '(inferior-emacs-lisp-mode-hook
emacs-lisp-mode-hook
scheme-mode-hook
clojure-mode-hook))
(add-hook hook #'smartparens-strict-mode))
Re: Emacs tips and tricks
Posted: Fri Jun 03, 2016 5:03 pm
by slartie
smartparens-strict-mode might be sorting that out for you, not sure.
Re: Emacs tips and tricks
Posted: Tue Jun 07, 2016 2:13 pm
by wuxmedia
Don't use old muscle memory and hit 'ctrl-z' to undo, otherwise...
Mark set....
hangs for like 5 mins...
What is that anyway like some sort of punishment?
Re: Emacs tips and tricks
Posted: Tue Jun 07, 2016 2:21 pm
by GekkoP
When in doubt, ask Emacs. :)
In this case: C-h k C-z.
Then, if you wish: (global-set-key (kbd "C-z") 'undo)
Re: Emacs tips and tricks
Posted: Tue Jun 07, 2016 8:09 pm
by wuxmedia
^ Ahh right, thanks. I suppose that is 'shell-like' behaviour :)
wouldn't do it if it was in the terminal...
Re: Emacs tips and tricks
Posted: Mon Aug 22, 2016 8:33 pm
by GekkoP
Re: Emacs tips and tricks
Posted: Sun Sep 18, 2016 7:41 am
by machinebacon
Was about time: integration of xwidgets (and thus, webkit)
https://www.youtube.com/watch?v=J2YdjpWJJHs
Re: Emacs tips and tricks
Posted: Sun Sep 18, 2016 11:31 am
by GekkoP
Schema validation for your lovely Emacs setup? Yes, please
https://manuel-uberti.github.io/emacs/2 ... /validate/
(oh wait, I know that guy. He's a good one, trust him.)