Today I finally took some time to fix a long-standing problem: when trying to edit a file on a remote host using Emacs tramp mode, long time-outs occurred when typing the remote file name (after hitting
C-x C-f). These time-outs were so long and occurred after each key press that tramp was effectively useless.
After some digging (e.g. excluding helm as the problem source) I found this entry in the Emacs Wiki which basically told my that using zsh (the Z shell) on the remote host could be the culprit. Indeed, after adding
[[ $TERM == "dumb" ]] && unsetopt zle && PS1='$ ' && return
at the top of my
~/.zshrc file solved the problem instantly. What this line does is simply replacing the shell prompt with a very simple one (a
$ followed by a space) if the terminal is of the
dumb type (which is the case for tramp).
Yesterday I installed Org2blog, which allows me to write my blog posts in Emacs org-mode and push them to my WordPress blog from within Emacs. So far I like it a lot! One less reason to leave Emacs :-), and hopefully also a reason to blog more often. Other good things about keeping your blog posts in Emacs are:
You can simply export them to e.g. PDF. In my current setup it’s a easy as adding the line
somewhere at the top of the file (before the actual text of the post starts) to tell org-mode that it should use my personal LaTeX export style, followed by
C-c C-e l o and a nicely formatted PDF of my blog post pops up.
- You keep all your blog posts in plain text format, so if you would decide to change to a different blogging platform, uploading the old posts should be fairly easy.
Org2blog’s GitHub page mentions
C-c p as prefix key for Org2blog’s functions, but in my case this prefix is already used by Projectile, and looking in Org2blog’s Customize Group I noticed that
C-c M-p is an alternative prefix, so I’m using that to get the following functionality:
C-c M-p p
C-c M-p P
|post buffer as page and publish
C-c M-p d
|post buffer as draft
C-c M-p D
|post buffer as page draft
C-c M-p t
This is the Org2blog configuration in my
.emacs file (note that I’m using John Wiegley’s
;; Configure Org2blog, which allows me to write blog posts in org-mode
;; and then push them to my WordPress blog.
:default-title "New blog post"
Some links to pages I read before trying Org2blog
Today I tried to upgrade Emacs Org-mode to version 8.3. I used the regular package upgrade, but got the following error:
Invalid function: org-babel-header-args-safe-fn
Unfortunately, Irreal’s advice to byte-compile
ob-R.el (twice) didn’t work out for me (by the way: thanks Planet Emacsen for aggregating so many useful posts!).
Browsing through some discussions on the emacs-orgmode mailing list it seemed that the error was due to org-mode being loaded while reinstalling the package. So I did the following:
- I started emacs without loading my personal settings:
Next I ran the following code from my
.emacs file in the scratch buffer (
M-x eval-region) to set up the package manager:
;; Add the original Emacs Lisp Package Archive
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
;; Add the user-contributed repository
'("marmalade" . "http://marmalade-repo.org/packages/"))
And finally I used the package manager to remove and then install the latest org package.
Now all is fine again! 🙂
And by the way: this is my first blog post using Org2blog!
As I discussed here, git allows you to commit only some of the changes you made to a given file. If you are working in Emacs you probably already know the wonders of Magit. In order to do the same partial committing of a file you can simply open
magit-status and go to the file you’re interested in. This will highlight the changed parts of the text. With your cursor in the changed block you’d like to commit simply press s and that change will be staged. If this is all you want press c to commit and you’re done!
Today I was working on an Emacs org-mode document that I wanted to export to PDF. The document contained several tables and for the PDF export I wanted to hide one of the columns in the table. Of course I could have removed the column in the org source, but since I might need it in the future that wasn’t really an option.
Searching the internet I came across this e-mail discussion on the org-mode mailing list, where radio tables were suggested. I briefly tried to get that working, but it seems that this is more of an option if you are working in e.g. a LaTeX document and want to use org-style formatted tables.
So I tried another search, this time on how to hide columns in LaTeX, having the idea in mind that I could then use that to fix the org-mode export. Thanks to question on
tex.stackexchange.com I came up with the followin solution:
First add the following lines at the top of the org file, after the regular org-mode header (if you have one):
This defines a new column type with the name
H (for ‘hidden’). Next, just before the table, simply add an
#+ATTR_LATEX: attribute (see the org-mode manual):
#+ATTR_LATEX: :align lHl
| col 1 | to be hidden | col3 |
| 1 | secret | info 1 |
| 2 | private | info 2 |
| 3 | hidden | info 3 |
When you export this to PDF (via C-c C-e lo) the table in the PDF only contains the first and last column.
After starting Emacs you end up in the
*scratch* buffer (assuming you’ve disabled the startup message in your
.emacs file). The
*scratch* can be used for writing down notes and some Lisp experiments (since it uses the Emacs Lisp major mode by default).
Now, I’m not very much of a Lisp programmer, but I do use Org-mode a lot. Consequently, I found myself changing the buffer’s major mode to org-mode regularly. And Emacs wouldn’t be Emacs if you couldn’t change this to a default. So, thanks to Bozhidar Batsov over at Emacs Redux, I’ve added the following lines to my Emacs configuration file:
;; Set the default mode of the scratch buffer to Org
(setq initial-major-mode 'org-mode)
;; and change the message accordingly
(setq initial-scratch-message "\
# This buffer is for notes you don't want to save. You can use
# org-mode markup (and all Org's goodness) to organise the notes.
# If you want to create a file, visit that file with C-x C-f,
# then enter the text in that file's own buffer.
After upgrading to Ubuntu 13.10 some time ago I noticed that my compose key (i.e. the key that you press followed by e.g.
, to create a
Ã§) didn’t work anymore in Emacs. I found two bug reports on this issue [1, 2], both effectively suggesting the same solution: start Emacs like this
So I added the following line to my
alias emacs='XMODIFIERS=@im=none emacs'
(of course somewhere before I set my
EDITOR variable). I also changed the command in the launcher I use (GLX-Dock/Cairo-Dock).
This doesn’t make it a system-wide (or even user-wide) fix, e.g. the Firefox add-on “It’s all text” doesn’t get it, but it covers most of my use cases.
I took some time today to configure my R experience. I’m mostly using R from Emacs using ESS (Emacs Speaks Statistics), which means I had to configure some settings there as well.
Previously, my settings only consisted of setting a customised directory in which to install my packages and an alias to start R without asking for saving the histroy when quitting. This I did by setting the following environment variable in my
.zshrc, as well as an alias:
# Set the library path for R
if [ -n "$(/usr/bin/which R 2>/dev/null)" ]; then
alias R="$(/usr/bin/which R) --no-save"
However, Emacs didn’t pick up either of these variables, so high time to fix that. This meant creating two files with the following content:
# Set the default CRAN repository used by install.packages()
options("repos" = c(CRAN = "http://cran-mirror.cs.uu.nl/"))
I added the following to my
.emacs file to start R with the
(setq inferior-R-args "--no-save ")
Additionally I have the following in there to turn on a spelling checker and have line-wraps enabled:
;; Set pdflatex as the default command for Sweave (default: texi2pdf)
(setq ess-swv-pdflatex-commands (quote ("pdflatex"
I use Emacs‘ org-mode a lot for writing notes, todo lists, presentations and writing short reports. Recently I started writing a larger report which I normally would have done in LaTeX. This time, since the notes related to the project were already in org format, I decided to write the whole report in org-mode. The one thing I needed for that was using BibTeX bibliographies (and RefTeX) from org-mode. A quick web search revealed that that can easily be done by adding the following to your
;; Configure RefTeX for use with org-mode. At the end of your
;; org-mode file you need to insert your style and bib file:
;; See http://www.mfasold.net/blog/2009/02/using-emacs-org-mode-to-draft-papers/
(defun org-mode-reftex-setup ()
(define-key org-mode-map (kbd "C-c )") 'reftex-citation)
(add-hook 'org-mode-hook 'org-mode-reftex-setup)
After that, RefTeX works, but exporting the org document to PDF (via LaTeX) didn’t include the bibliography entries. A quick look at the error log showed that
bibtex hadn’t been run, so the question was: how to tell org-mode to do that too when exporting. The answer is to tell org-mode to use the
latexmk Perl script (on Debian/Ubuntu it is easily installed from the package repositories) when exporting to PDF. I added the following lines to my
;; Use latexmk for PDF export
(setq org-latex-to-pdf-process (list "latexmk -pdf -bibtex %f"))
Today Planet Emacsen brought me Irreal’s second blog post in a short time on CUA mode in Emacs. So far I’ve always ignored it because as far as I knew CUA mode is about getting the Windows keyboard shortcuts of Ctrl-c, Ctrl-x and Ctrl-v for copying and pasting to Emacs. The thing is, I date back to the DOS era when Shift-Del and Shift-Ins were used for that, so back in my Windows days I never got used to those ‘new’ keyboard shortcut. Now that I’ve been an Emacs user for more than a decade I’m so used to C-w and C-y and I see no reason for having the Windows shortcuts work in Emacs.
Back to Irreal. In his recent blog posts he writes about a subset of cua-mode: cua-selection-mode. The video by Mark Mansour that we writes about says it all (it’s short, so go and watch it!). What cua-selection-mode is all about is rectangle editting. So far I’ve been using the regular Emacs keys for rectangle selection and editing (basically C-space to select a rectangle and C-r-k to cut it, C-r-t to insert text and C-r-y to paste a rectangle). By setting
~/.emacs file you only enable the rectangle features of CUA mode.
So, for those that didn’t watch the video, what does the rectangle editing mean? It means that you can for example simply insert a list of increasing numbers in a text (this may come in handy in an org-mode table for example), or you can insert the same text in front of and/or behind a selected column of text.
Key combos to remember are:
- C-return: Start selection
- return: move the cursor to top-left, top-right, bottom-left and bottom-right corner of the selected rectangle
- C-?: briefly list the available key combinations (with rectangle selection enabled)
- M-i: if the selection is a column of numbers increase the numbers (by one)
- M-n: Insert a number in the column (asks for start value and increment value)
- C-1 C-w: Kill (cut) the contents of the rectangle to register 1 (you can use number 0–9 for different registers). Using C-1 C-y yanks (pastes) the rectangle at the cursor position.