Emacs tips and tricks

Forum rules
Share your brain ;)
User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Thu Dec 04, 2014 7:40 pm

I don't like doc-view that much, especially since it doesn't work with pdfs the way a common pdf reader does. Fortunately, I found this: https://github.com/politza/pdf-tools

Had to get libpoppler-private-dev from experimental to compile it, but who cares. Works and feels good.
Image

User avatar
Dr_Chroot
Alfalfa
Posts: 1100
Joined: Mon Jun 09, 2014 9:49 pm
Location: among the sagebrush
Contact:

Re: Emacs tips and tricks

Unread post by Dr_Chroot » Thu Dec 04, 2014 10:40 pm

^ Thanks, Gekko! I have been using xpdf for a while instead of doc-view-mode for the same reason. This is exactly what I need :D
Fight internet censorship.
EFF | Tor Project | Bitcoin

"There have been times throughout American history where what is right is not the same as what is legal. Sometimes to do the right thing you have to break the law." - Edward Snowden

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Emacs tips and tricks

Unread post by machinebacon » Mon Dec 15, 2014 2:31 am

Don't know if it has been mentioned before.

multi-term (M/ELPA), I used this setup, works nicely.
http://paralambda.org/2012/07/02/using- ... -emulator/
..gnutella..

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Wed Dec 17, 2014 10:48 am

^ Interesting. Wonder if something similar could be done for eshell.

There seem to be A LOT of fuzz about Helm: http://tuhdo.github.io/helm-intro.html
I have been trying to switch from ido to helm lately (one reason: https://tuhdo.github.io/helm-intro.html#sec-14), but failed horribly. I found Helm too much of a bloat and I can't see any improvement on my productivity using that.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Wed Dec 17, 2014 7:29 pm

^ not true.
I dediced to spend some time with helm, replacing ido and try to stick with it. A casual look at helm isn't enough to appreciate its power, I think. Anyway. Here's my helm setup. Mostly from here, but with some fine adds.

Code: Select all

;; Helm setup
(require 'helm-config)
(helm-mode 1)

;; The default "C-x c" is quite close to "C-x C-c", which quits Emacs.
;; Changed to "C-c h". Note: We must set "C-c h" globally, because we
;; cannot change `helm-command-prefix-key' once `helm-config' is loaded.
(global-set-key (kbd "C-c h") 'helm-command-prefix)
(global-unset-key (kbd "C-x c"))

(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action) ; rebind tab to run persistent action
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB works in terminal
(define-key helm-map (kbd "C-z")  'helm-select-action) ; list actions using C-z

(setq helm-split-window-in-side-p           t ; open helm buffer inside current window, not occupy whole other window
      helm-move-to-line-cycle-in-source     t ; move to end or beginning of source when reaching top or bottom of source.
      helm-ff-search-library-in-sexp        t ; search for library in `require' and `declare-function' sexp.
      helm-scroll-amount                    8 ; scroll 8 lines other window using M-<next>/M-<prior>
      helm-ff-file-name-history-use-recentf t)

(global-set-key (kbd "M-x") 'helm-M-x)
(setq helm-M-x-fuzzy-match t) ;; optional fuzzy matching for helm-M-x

(global-set-key (kbd "M-y") 'helm-show-kill-ring)

(global-set-key (kbd "C-x b") 'helm-mini)
(setq helm-buffers-fuzzy-matching t
      helm-recentf-fuzzy-match t)

(global-set-key (kbd "C-x C-f") 'helm-find-files)

;; C-h is delete-backward-char, don't touch it!
(eval-after-load "helm-files"
  '(let ((helm-find-files-C-h-map (lookup-key helm-find-files-map (kbd "C-h"))))
     ;; make sure C-h is no longer a prefix key
     (define-key helm-find-files-map (kbd "C-h") nil)
     ;; rebind "C-h ..." to "M-m ..." to preserve functionality
     (define-key helm-find-files-map (kbd "M-m") helm-find-files-C-h-map)))

(setq helm-semantic-fuzzy-match t
      helm-imenu-fuzzy-match t)

(add-to-list 'helm-sources-using-default-as-input 'helm-source-man-pages)

(global-set-key (kbd "C-c h o") 'helm-occur)

(setq helm-apropos-function-list t)

(require 'helm-eshell)
(add-hook 'eshell-mode-hook
          #'(lambda ()
              (define-key eshell-mode-map (kbd "C-c C-l") 'helm-eshell-history)))

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Thu Dec 18, 2014 7:09 pm

Since I got a small part in this one (mainly beta-testing it), I will put it here: browse StackExchange straight from Emacs with sx.el.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Emacs tips and tricks

Unread post by machinebacon » Tue Dec 23, 2014 6:17 am

Umlauts (or any other unicode shit) in Emacs? Remember C-x 8 RET

Code: Select all

C-x 8 .		·
C-x 8 /		Prefix Command
C-x 8 1		Prefix Command
C-x 8 3		Prefix Command
C-x 8 <		«
C-x 8 =		¯
C-x 8 >		»
C-x 8 ?		¿
C-x 8 C		©
C-x 8 L		£
C-x 8 P		¶
C-x 8 R		®
C-x 8 S		§
C-x 8 Y		¥
C-x 8 ^		Prefix Command
C-x 8 _		Prefix Command
C-x 8 `		Prefix Command
C-x 8 c		¢
C-x 8 m		µ
C-x 8 o		°
C-x 8 u		µ
C-x 8 x		×
C-x 8 |		¦
C-x 8 ~		Prefix Command

C-x 8 ~ SPC	~
C-x 8 ~ A	Ã
C-x 8 ~ D	Ð
C-x 8 ~ N	Ñ
C-x 8 ~ O	Õ
C-x 8 ~ T	Þ
C-x 8 ~ a	ã
C-x 8 ~ d	ð
C-x 8 ~ n	ñ
C-x 8 ~ o	õ
C-x 8 ~ t	þ
C-x 8 ~ ~	¬

C-x 8 ` SPC	`
C-x 8 ` A	À
C-x 8 ` E	È
C-x 8 ` I	Ì
C-x 8 ` O	Ò
C-x 8 ` U	Ù
C-x 8 ` a	à
C-x 8 ` e	è
C-x 8 ` i	ì
C-x 8 ` o	ò
C-x 8 ` u	ù

C-x 8 _ a	ª
C-x 8 _ o	º

C-x 8 ^ SPC	^
C-x 8 ^ 1	¹
C-x 8 ^ 2	²
C-x 8 ^ 3	³
C-x 8 ^ A	Â
C-x 8 ^ E	Ê
C-x 8 ^ I	Î
C-x 8 ^ O	Ô
C-x 8 ^ U	Û
C-x 8 ^ a	â
C-x 8 ^ e	ê
C-x 8 ^ i	î
C-x 8 ^ o	ô
C-x 8 ^ u	û
I'm sure you all know it already ;)

Note to self (and gekko's wife): for Chinese pinyin input in Emacs, C-\ py
No fucking IME needed :)
..gnutella..

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Tue Dec 23, 2014 9:08 am

^ Oh yes, that Chinese pinyin trick is a slap in that face of poor iBus! ;)

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Wed Dec 24, 2014 10:44 am

Flycheck: http://www.lunaryorn.com/2014/12/23/my- ... -0.22.html

Been avoiding this package for way too long. My bad. On-the-fly syntax checking is really helping me a lot in writing better code and understand it better. Probably only for the OCD minds out there.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Sun Dec 28, 2014 3:57 pm

Better init file? https://github.com/jwiegley/use-package
My configuration grows every day, I don't know if I have the strength to refactor all of it to use this package.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Emacs tips and tricks

Unread post by machinebacon » Sun Dec 28, 2014 4:55 pm

^ Yeah, that's like re-partition just to try btrfs ;)

Fancier mode line? Powerline style in Emacs? -> https://github.com/Bruce-Connor/smart-mode-line
Of course also more here: http://www.emacswiki.org/emacs/ModeLineConfiguration
..gnutella..

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Sun Dec 28, 2014 9:27 pm

^ Using that smart-mode-line lately. Still have to understand how to hide some modes I don't really care having in the mode line, but it is a pretty good package.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Mon Dec 29, 2014 2:57 pm

Ok, since today in the office there is nobody around I refactored all my configuration to use that use-package. Looks cleaner and easier to maintain. If anyone interested, it is here: https://github.com/boccaperta-it/emacs

And to hide undesired modes when using smart-mode-line:

Code: Select all

setq rm-blacklist (quote (" my-keys-mode"
			       " PgLn"
			       " Projectile"
			       " company"
			       " Undo-Tree"))

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Wed Jan 07, 2015 3:46 pm

One more praise about use-package, and then I STFU. Try:

Code: Select all

M-x emacs-init-time RET
upon startup before and after using use-package. Definitely worth it. :)

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Emacs tips and tricks

Unread post by machinebacon » Sun Jan 11, 2015 4:52 pm

Has anybody tried the Hemlock already? http://www.common-lisp.net/project/phemlock/

I couldn't get it to run (weeks ago! don't remember what the problem was -- the (ed) in cmucl [ cmucl-source package in Debian ] as shown here http://www.cons.org/cmucl/hemlock/index-print.html didn't do it)

For those who want to have an Emacs-like edtor in the browser, there's http://www.ymacs.org/ (check the demo!)
..gnutella..

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Mon Jan 12, 2015 9:24 pm

Didn't know about Hemlock. We need good ol' Joe for this one. ;)

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Tue Jan 13, 2015 5:54 pm


User avatar
DebianJoe
Frame Buffer
Posts: 1915
Joined: Mon Jul 01, 2013 5:41 am
Location: emacs.d

Re: Emacs tips and tricks

Unread post by DebianJoe » Tue Jan 13, 2015 6:10 pm

GekkoP wrote:Didn't know about Hemlock. We need good ol' Joe for this one. ;)
Sorry, just now caught up on this thread. What do I need to make happen? Hemlock in Debian? I will give it a go sometime.

(Edit: Perhaps not getting to this soon, if ever. I'm having a bit of trouble managing some IRL stuff right now.)
|>>BBQ Roaster, Alpha Branch<< | >> clinky << | >> X11 must die << |
Thanks BASIC

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: Emacs tips and tricks

Unread post by GekkoP » Thu Jan 15, 2015 7:20 pm

Masters say: to avoid your left pinky finger to be hurt real bad by all those wacky keybindings, use Caps Lock as left Ctrl key.
I've been trying it out for a while and seems to work for me.

On LinuxBBQ Haggis I just added this to my .xinitrc

Code: Select all

setxkbmap -option ctrl:nocaps
This line does not swap Caps Lock and left Ctrl, as some of the masters suggest, but simply adds Caps Lock as an extra Ctrl key. Because I always liked telling my masters "in your face!". Or something like that.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Emacs tips and tricks

Unread post by machinebacon » Fri Jan 16, 2015 1:53 am

^ The only useful thing to do with Caps Lock. I also hate the suggestion of 'switching' these two. Caps Lock is so 1950s :)

(And Happy 2222 posts to you, gekko!)
..gnutella..

Post Reply