Emacs tips and tricks
Forum rules
Share your brain ;)
Share your brain ;)
Emacs tips and tricks
Navigating and editing in emacs using the keyboard.
Re-read it until you master it...
Make a cheat-sheet of the mentioned commands.
http://www.masteringemacs.org/articles/ ... -movement/
Re-read it until you master it...
Make a cheat-sheet of the mentioned commands.
http://www.masteringemacs.org/articles/ ... -movement/
Connected. Take this REPL, brother, and may it serve you well.
Re: Emacs tips and tricks
...but all those wacky keybinds. 8)
Re: Emacs tips and tricks
No perfection without some amount of suffering...
Connected. Take this REPL, brother, and may it serve you well.
Re: Emacs tips and tricks
thanks, bookmarked!
Re: Emacs tips and tricks
One of my favorite tricks is the column selection. It is really helpful when I'm editing a file and I want to copy/cut a rectangular portion of the text.
Here's what I do:
M-x cua-mode
Place point at the beginning of the text I want to select
C-Enter
Select the text using C-f and C-n.
C-k to cut (or M-w to copy)
C-y to paste somewhere else in the file
cua-mode also enables the """standard""" copy/cut/paste using C-c/C-x/C-v, but I stick with Emacs keys. You can also enable just cua-selection-mode, if you don't care about C-c/C-x/C-v.
Here's what I do:
M-x cua-mode
Place point at the beginning of the text I want to select
C-Enter
Select the text using C-f and C-n.
C-k to cut (or M-w to copy)
C-y to paste somewhere else in the file
cua-mode also enables the """standard""" copy/cut/paste using C-c/C-x/C-v, but I stick with Emacs keys. You can also enable just cua-selection-mode, if you don't care about C-c/C-x/C-v.
Re: Emacs tips and tricks
easily start a version of emacs with alternate configuration
http://www.emacsbites.com/episode/scratch-emacs
http://www.emacsbites.com/episode/scratch-emacs
Connected. Take this REPL, brother, and may it serve you well.
Re: Emacs tips and tricks
^ cool one, especially for testing random stuff I pulled in from the repos.
Re: Emacs tips and tricks
What!?
RMS doesn't know how to use org-mode? Damn, that hurts.
RMS doesn't know how to use org-mode? Damn, that hurts.
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Emacs tips and tricks
^ I suppose he doesn't even know how to use a web browser, since he sends snapshots of websites via a crawler to his email box.
..gnutella..
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Emacs tips and tricks
http://www.finseth.com/craft/
Title The Craft of Text Editing: Emacs for the Modern World
Author(s) Craig A. Finseth
Publisher: Lulu.com; 3rd edition (March 17, 2006)
Paperback 228 pages
eBook Online, HTML, PDF files
Language: English
ISBN-10: 1411682971
ISBN-13: 978-1411682979
Title The Craft of Text Editing: Emacs for the Modern World
Author(s) Craig A. Finseth
Publisher: Lulu.com; 3rd edition (March 17, 2006)
Paperback 228 pages
eBook Online, HTML, PDF files
Language: English
ISBN-10: 1411682971
ISBN-13: 978-1411682979
..gnutella..
Re: Emacs tips and tricks
yeah, thanks!
Re: Emacs tips and tricks
I prefer directories grouped at the beginning, in an xterm as well as in emacs.
For the xterm, update your ~/.bashrc to include the alias
For emacs, custumize group 'dired': Alt-x customize-group, enter dired and edit the entry 'Dired Listing Switches' as in the scrot.
Then click 'Apply and Save' if you want it to stick.
For the xterm, update your ~/.bashrc to include the alias
Code: Select all
alias ls='ls --color=auto --group-directories-first'
Then click 'Apply and Save' if you want it to stick.
Connected. Take this REPL, brother, and may it serve you well.
Re: Emacs tips and tricks
^ nice one!
Re: Emacs tips and tricks
Some bloat you may need: http://skybert.net/emacs/a-handful-pack ... your-emacs
Re: Emacs tips and tricks
Package managers for emacs:
- the native `package.el'
- el-get: if you prefer the latest and greatest from git repo's
- cask: built on `package.el'
now at version 0.6. Allows you to build your own packages.
Pick the one you prefer, depending also on how adventurous you are.
- the native `package.el'
- el-get: if you prefer the latest and greatest from git repo's
- cask: built on `package.el'
now at version 0.6. Allows you to build your own packages.
Pick the one you prefer, depending also on how adventurous you are.
Connected. Take this REPL, brother, and may it serve you well.
Re: Emacs tips and tricks
Firefox like Emacs? Yes, here it is.
Re: Emacs tips and tricks
Ok, finally my days of elisp are paying off. I also know DebianJoe would be proud of me because of this one.
I don't know if any of you have to deal with .po files. Dealing with translations (and translators) I have to deal with those files. I don't want to use poedit for that because of gtk3, so Emacs to the rescue.
Emacs has a mode for .po files: po-mode. If you have followed DebianJoe's tips and tricks about el-get in Emacs (and if not, shame on you), po-mode is just a matter of el-get-install.
By default, when you finish your .po file editing and validate it via po-mode hitting 'V', no .mo file is generated. Po-mode redirects msgfmt to /dev/null and that's not what I need. Basically I need the .mo file, because of some wordpress themes and plugins I usually work with.
So I opened ~/.emacs.d/el-get/po-mode/po-mode.el and changed this function:
To this:
Then, in Emacs you just need to do a M^x byte-compile-file. That's it. Restart Emacs, edit your .po files and enjoy the .mo files created for you in your working directory.
(there surely is a better solution to the problem, my elisp is not that good, but it works for me and no need to use poedit anymore)
I don't know if any of you have to deal with .po files. Dealing with translations (and translators) I have to deal with those files. I don't want to use poedit for that because of gtk3, so Emacs to the rescue.
Emacs has a mode for .po files: po-mode. If you have followed DebianJoe's tips and tricks about el-get in Emacs (and if not, shame on you), po-mode is just a matter of el-get-install.
By default, when you finish your .po file editing and validate it via po-mode hitting 'V', no .mo file is generated. Po-mode redirects msgfmt to /dev/null and that's not what I need. Basically I need the .mo file, because of some wordpress themes and plugins I usually work with.
So I opened ~/.emacs.d/el-get/po-mode/po-mode.el and changed this function:
Code: Select all
(defun po-validate ()
"Use 'msgfmt' for validating the current PO file contents."
(interactive)
; The 'compile' subsystem is autoloaded through a call to (compile ...).
; We need to initialize it outside of any binding. Without this statement,
; all defcustoms and defvars of compile.el would be undone when the let*
; terminates.
(require 'compile)
(let* ((dev-null
(cond ((boundp 'null-device) null-device) ; since Emacs 20.3
((memq system-type '(windows-nt windows-95)) "NUL")
(t "/dev/null")))
(compilation-buffer-name-function
(function (lambda (mode-name)
(concat "*" mode-name " validation*"))))
(compile-command (concat po-msgfmt-program
" --statistics -c -v -o " dev-null " "
(shell-quote-argument buffer-file-name))))
(po-msgfmt-version-check)
(compile compile-command)))
Code: Select all
(defun po-validate ()
"Use 'msgfmt' for validating the current PO file contents."
(interactive)
; The 'compile' subsystem is autoloaded through a call to (compile ...).
; We need to initialize it outside of any binding. Without this statement,
; all defcustoms and defvars of compile.el would be undone when the let*
; terminates.
(require 'compile)
(let* ((compilation-buffer-name-function
(function (lambda (mode-name)
(concat "*" mode-name " validation*"))))
(compile-command (concat po-msgfmt-program
" --statistics -c -v -o "
(substring buffer-file-name 0 -2) "mo "
(shell-quote-argument buffer-file-name))))
(po-msgfmt-version-check)
(compile compile-command)))
(there surely is a better solution to the problem, my elisp is not that good, but it works for me and no need to use poedit anymore)
Re: Emacs tips and tricks
So, org-mode.
A neat trick with this one is org2blog. What is org2blog? It is just an easy way to write and publish your blog posts without leaving your favorite text editor. I only tested it with my website, which is working on Wordpress, so I cannot guarantee it will work with other platforms. Also, this is what I did and it may not be the only and best way to setup org2blog.
Let's go.
First of all, my Emacs 24.3.1 had Org 7.x instead of 8.x. We need 8.x version, otherwise errors like "Cannot open load file ox-html" will scare us away. Check what version of Org you have with M^x org-version. If you don't have 8.x, just get it with git like this:
Now we can safely add this to our .emacs (double check your paths, of course):
Do a M^x org-version just to check that everything worked as you were expecting.
We need bzr to install org2mode, so:
Now we need to install org2blog and some other packages it needs to properly work. In Emacs, using el-get or package-install or whatever you use to grab packages, install the followings:
Then we can add this to our lovely .emacs (double check your paths, of course):
We're almost there.
In Emacs now you can do M^x org2blog/wp-login and you will be prompted for your password. Once logged in, do a M^x org2blog/wp-new-entry and start writing your cool poetry.
Org2blog will let you define, among other things, categories, tags, description, title and of course the text you want to be published.
Once you are done with the writing, it is time for the publishing. Just hit M^x org2blog/wp-post-buffer and you will find your post in draft on your website.
A neat trick with this one is org2blog. What is org2blog? It is just an easy way to write and publish your blog posts without leaving your favorite text editor. I only tested it with my website, which is working on Wordpress, so I cannot guarantee it will work with other platforms. Also, this is what I did and it may not be the only and best way to setup org2blog.
Let's go.
First of all, my Emacs 24.3.1 had Org 7.x instead of 8.x. We need 8.x version, otherwise errors like "Cannot open load file ox-html" will scare us away. Check what version of Org you have with M^x org-version. If you don't have 8.x, just get it with git like this:
Code: Select all
git clone git://orgmode.org/org-mode.git
cd org-mode
make
Code: Select all
;; Org-mode
(add-to-list 'load-path (expand-file-name "~/org-mode/lisp"))
(add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))
(require 'org)
We need bzr to install org2mode, so:
Code: Select all
sudo apt-get install bzr
Code: Select all
M^x el-get-install RET xml-rpc
M^x el-get-install RET metaweblog
M^x el-get-install RET org2blog
M^x el-get-install RET htmlize
Code: Select all
;; org2blog setup
(add-to-list 'load-path "~/.emacs.d/el-get/metaweblog")
(add-to-list 'load-path "~/.emacs.d/el-get/xml-rpc-el")
(add-to-list 'load-path "~/.emacs.d/el-get/org2blog")
(add-to-list 'load-path "~/.emacs.d/el-get/htmlize")
(require 'org2blog-autoloads)
(setq org2blog/wp-blog-alist
'(("my-blog"
:url "http://our.website.com/xmlrpc.php"
:username "our_username")))
(setq org2blog/wp-use-sourcecode-shortcode 't)
(setq org2blog/wp-sourcecode-default-params nil)
In Emacs now you can do M^x org2blog/wp-login and you will be prompted for your password. Once logged in, do a M^x org2blog/wp-new-entry and start writing your cool poetry.
Org2blog will let you define, among other things, categories, tags, description, title and of course the text you want to be published.
Once you are done with the writing, it is time for the publishing. Just hit M^x org2blog/wp-post-buffer and you will find your post in draft on your website.