Feeds:
Posts
Comments

Posts Tagged ‘emacs news’

Org Mode

The wonderful Org mode has deservedly been getting a lot of [word] press recently. This is a really great tutorial. There is a nice customization guide at orgmode.org. endperform talks about using it for time tracking and remembering useful tricks. Emacs-fu has an article on generating html with org-mode. ByteBaker talks about using it to organise papers he downloaded and to make a wiki.

My Emacs Posts

I’ve started a series about a light-weight alternative to dired mode. Part two, which will remember locations you have visited previously is on the way.

A quick mention of longlines-mode got a comment about visual-line-mode which is the replacement in Emacs 23 onwards. I’ve switched over and it does seem better. longlines-mode was fairly reliable, but occasionally it would forget that it was supposed to be wrapping words and I would need to disable it and enable it.

Other Emacs Posts

alieniloquent talks about using advice to disable other window is you use the universal prefix (C-u). Nice trick.

Aneesh Kumar has post on switching from vim to emacs, or actually viper. As I use vim a lot, I’ve tried viper in the past but I always found that it made accessing various emacs commands harder (or maybe just different) than it is in vanilla emacs so I always switched back.

Armin Sadeghi says that his two favourite editors are SlickEdit and Emacs.

The big difference between SlickEdit and Emacs is that SlickEdit is commercial software and Emacs is open source.

If that is the big difference, why not just use Emacs?

Read Full Post »

HowTo Disable indent-tabs-mode

It sounds like this guy is having problems with emacs automatically converting spaces to tabs. I can sympathise – it took me a while to figure out how to disable indent-tabs-mode correctly.

My post also received a comment asking how to add a tabs if you have disabled indent-tabs-mode. If you need a single tab, use C-q <TAB> (quoted-insert). Otherwise, if you need to enter many tabs you can enable M-x eval-expression <RET>(setq indent-tabs-mode t)<RET> or bind tab to (self-insert-command).

Working With Multiple Databases

To much wailing and nashing of teeth, several weeks ago I introduced my emacs db mode. I have made an extension for quickly and easily switching between multiple databases using ido. It also serves as a nice tutorial for adding custom sections to the mode-line.

Always Prompting Before Exiting Emacs

Nilesh has a post about prompting before exiting to avoid accidents. Now, I occasionally want a prompt – I often get a prompt anyway as I have either processes or unsaved buffers. Occasionally I am caught out when I am sketching things out in scratch buffers (with, e.g. C-x b *stuff* <RET>).

Most functions that are called when emacs is exiting call (save-buffers-kill-emacs) which has a customizable variable you can set to control if and how emacs prompts when exiting. I like to timeout these type of prompts, just in case I was attempting to exit while the screen was off.

(setq confirm-kill-emacs
      (lambda (e) 
        (y-or-n-p-with-timeout
         "Really exit Emacs (automatically exits in 5 secs)? " 5 t)))

Emacs As A Windows Editor?

There was a strange thread in the Joel On Software forums. Someone wanted an alternative to Emacs on Windows with the following features:

  • macros
  • good windows integration
  • syntax highlighting for multiple file types
  • free as in beer

Why strange? Well, emacs has all of this and more. Keyboard macros are available with C-x ( and C-x ) or <f3> <f4> in more modern versions. In addition, Emacs 23 is extremely good-looking.

Setting cua-mode and recentf will get you most of the way to that authentic windows app experience.

(cua-mode t)
(recentf-mode t)

Remember to use the Emacs Win32 build.

Miscellaneous Tips

Here is a mention of the fantastic occur command.

Someone made a brief post (http://rydow.wordpress.com/2009/06/11/emacs-history-between-sessions) about savehist-mode although they couldn’t remember where they had seen the original. Along with many great Emacs hints, it was from Emacs-fu (it was in a comment by valvo).

Read Full Post »

Useful Blog Comments

Nachopp demonstrates some emacs lisp that inserts a commonly used find command in a shell buffer. And Ian Eure has a great follow-up comment which demonstrates the more typical way of defining emacs lisp functions; talks about alternatives such as abbrev mode and yasnippet and finally mentions the best solution, the built-in rgrep.

Defining C++ styles

David Ha has a gallery of some of the built-in C++ styles. None of the styles suit me exactly so I have accreted a fair amount of C++ configuration code over the years. I must admit, I haven’t audited for ages so I’m not sure which bits are necessary and which are not.

(defconst *my-cc-style*
  '((c-basic-offset . 4)
    (c-comment-only-line-offset . 0)
    (c-hanging-braces-alist . ((brace-list-open)
                               (brace-entry-open)
                               (substatement-open after)
                               (block-close . c-snug-do-while)))
    (c-cleanup-list . (brace-else-brace))
    (c-offsets-alist . ((statement-block-intro . +)
                        (knr-argdecl-intro     . 0)
                        (substatement-open     . 0)
                        (substatement-label    . 0)
                        (innamespace           . 0)
                        (case-label            . +)
                        (statement-cont        . +)))))

(defun my-c-initialization-hook ()
  (define-key c-mode-base-map "\C-m" 'c-context-line-break)
  (define-key c-mode-base-map (kbd "RET") 'newline-and-indent)
  (define-key c-mode-base-map [f7] 'run-compile))

(add-hook 'c-initialization-hook 'my-c-initialization-hook)
(setq c-offsets-alist '((member-init-intro . ++)))

(c-add-style "PERSONAL" *my-cc-style*)

(defun my-c-mode-common-hook ()
  (c-set-style "PERSONAL")
  (setq tab-width 4
        indent-tabs-mode nil
        c-hungry-delete-key t)
  (c-toggle-auto-newline 1))

(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

The most useful commands for finding out which of the variables to set are C-c C-o (c-set-offset) and C-c C-s (c-show-syntactic-information)

This is kinda interesting where Ronnie Collinson (from the NotThinking blog)
removes the *compilation* buffer if the compile is successful. It isn’t something I personally would use as I like the feedback, but I wasn’t previously thinking about compilation-finish-functions and I have a few ideas of things I would like to run after a successful compile.

Perennial Emacs Blog Topics

There are a few perennial blog topics in the emacs world – I mentioned a smooth scrolling post in my links from 2009/17 and here is Da Zhang’s take (does anyone like the default behaviour by the way?). I included a link to a post on the incredibly useful mark ring in emacs-links-2009-09 and here is another from yesterday.

Proposed solutions – fix the smooth scrolling behaviour so it works nicely out of the box and… well, perhaps blogs are not a great way of educating the masses after all. Pity.

Read Full Post »

Emacs-fu Emacs Tips

Emacs-fu started a great post requesting little tricks. I gave my own response, covering cut-and-paste, ido mode, uniquify and tidy backups. Da Zhang has a nice summary of some of the other tips.

Using/Extending Core Libraries

There are a few emacs libraries that store current state in global variables. For example, ido stores the list of current matches in ido-matches. Accessing this variable while filtering using ido can be a little convoluted. I gave an example of how to do this in Shell Command on Multiple Buffers.

Dabbrev also uses global variables although it provides [internal] functions for completing an abbreviation. I have a complete example at Autocomplete with a Dabbrev Twist but the core is very simple:

(let ((dabbrev-check-all-buffers t))
  (dabbrev--reset-global-variables)
  (dabbrev--find-all-expansions <abbreviation> t))

Multi-file Search/Replace

I really liked this post from Ian Eure demonstrating how to do multi-file search and replace in emacs. I frequently see emacs proponents saying its awesome and you’ll know when you reach emacs nirvana so it is nice to see a practical demonstration of emacs power. And of course I know it is possible in shell but the simplicity and the interactive nature of emacs makes this a much more pleasant experience. A quick summary:

  • M-x find-grep-dired RET <pattern> (put matching files in dired buffer)
  • m .php$ RET (mark all php files)
  • Q <pattern> RET <replace string> (run query-replace on marked files)
  • C-x s (save all modified files)

Emacs Popularity

So first of all I found this post referring to a thread where a guy says he recommends nano as he has used Unix-like systems that don’t have vi. Hmmm… okay, and then that post has this one from 2007 in the auto-generated links list about Emacs losing in popularity.

And from there I get to this one which has a poll where 56% of the almost 750 respondants chose vim1 as their favourite Linux text editor compared to 9% choosing emacs. Of course it is a highly unscientific result, but do you think more than 6 times as many people use vim as emacs?


1. Fair enough – it is a fine editor

Read Full Post »

The MuuWiki has a comprehensive review of Predictive which is a module that performs a similar function to predictive text in mobile phones. I’ve been looking for something that will help write posts quicker for a while. Could this help? I suspect the answer is no – thought is the limiting factor, but I’m going to try it out for a while. You can download it here.

Note that when I compiled the .el files as recommended, it took several minutes to compile dict-english.el but it did finish eventually.

Another useful tool to help with the writing is flyspell. It works ‘out of the box’ on Linux. To get it working on Windows, you need some help from Cygwin.

If you scrolling through a buffer by holding down C-n then the buffer frequently jumps as it re-centers. I find this very difficult to follow. This post explains how to fix it. As mentioned in the comments it is more difficult than it sounds.

Making emacs prettier is a common theme (if you’ll pardon the pun). I’ve pointed out a few related posts myself. This one actually convinced me to try out the color-theme package. I tried the emacs wombat color-theme as recommended which I quite liked but so far my favourite is color-theme-calm-forest.

Read Full Post »

I’ve written the third post in the comint series. Database Mode is a more traditional use of comint mode to interact with an external interpreter. Part 1 described basic use of comint with a cut-down shell mode and Part 2 was about a stock price subscriber.

There is a great tip from emacs-fu on using a custom menu to store all the tips you’ve been reading on blogs like my own.

Ben Atkin mentions a couple of things of things that I really like about emacs. First of all, he talks about the ability to see different parts of the same buffer in two frames. I use this all the time when all my constants (or whatever) are at the top of the file. Admittedly, a trick I’ve linked to before with C-x C-x to return to where you were also works nicely in this case.

And the other thing was the scratch buffer. The great thing about emacs is you can easily create another buffer with C-x b and store whatever you like in there.

There is a nice example of Kit OConnell asking the internet for help with an emacs issue. In the end it looks like it was solved in the real world by someone spotting some "smart quotes" in the .emacs. Perhaps emacs should warn about that at start-up.

There have been a few posts on whitespace recently. Matt Harrison mentions a whitespace mode that can be useful for the pythonistas that have the most trouble with inconsistent whitespace. Rémi Vanicat isn’t the first person to talk about removing trailing whitespace (I linked to an even better solution in an earlier link roundup). It is nice that emacs has such a nice way of dealing with it.

Read Full Post »

Nik Conwell posted about the Firefox extension mozex which reminds me I need to set that up. I imagine that this will combine nicely with the emacs client trick mentioned in windows and daemons.

I’ve started a mini-series on Emacs comint as I feel it deserves a lot more love than it gets, considering how incredibly useful it is.

Last year, emacs-fu wrote about extending ansi-term. My own recent post on wrapping ansi-term goes even further, configuring the mouse to auto-copy on highlight and using ido to quickly and easily switch between multiple shell buffers.

Still on the ansi-term topic, sadly it doesn’t work for me in windows. And by default, M-x shell starts a DOS prompt. martinez has a fix for this in NTEmacs although the following works a little better for me in EmacsW32 1.58.

(setq explicit-bash-args '("--login" "-i"))
(setq explicit-shell-file-name "c:/packages/cygwin/bin/bash")
(setenv "SHELL" explicit-shell-file-name)

(add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)

I can’t think of a time I would like to keep trailing whitespace. However, if you need it, flameyes has a solution to selectively remove it or keep it under different directories subtrees. This nicely demonstrates directory local variables (which have been mentioned by previous commenters on this blog).

Read Full Post »

Older Posts »

Follow

Get every new post delivered to your Inbox.