The daemon feature of Emacs is great. But when should the daemon be started?
At one time I used an '@reboot' line in my crontab. But when you want to use things like Tramp mode (for editing files on remote servers transparently), you very quickly wish that emacs could talk to your ssh-agent.
So if you accept that you will be running a desktop environment (not always true), you can add the daemon to your equivalent of "System >> Preferences >> Startup Programs".
But then you find that Flymake (when used with cperl-mode) is not picking up any of your uninstalled, work-in-progress Perl modules. Wouldn't it be great if you could set $PERL5LIB to fix this? And doesn't M-x copyright require you to set "$ORGANIZATION"?
Ever since Debian bug #411639 was fixed at the end of 2007, we have the option of "~/.xsessionrc" for setting environment variables that will cover everything in your desktop session, including things launched from panels and startup scripts.
So now that's what I do. But I've yet to figure out a good equivalent for console-only systems. Maybe I don't need one?
Posted: 16 Jul 2010 23:48 |
Today I improved the function I was using to toggle full screen in GNU Emacs.
(defun toggle-fullscreen (&optional f) (interactive) (let ((current-value (frame-parameter nil 'fullscreen))) (set-frame-parameter nil 'fullscreen (if (equal 'fullboth current-value) (if (boundp 'old-fullscreen) old-fullscreen nil) (progn (setq old-fullscreen current-value) 'fullboth))))) (global-set-key [f11] 'toggle-fullscreen)
The previous function would always restore the frame to "normal" state, even if Emacs was previously maximized. This one makes it behave more like, say, Epiphany or Totem.
Apparently using GNOME Keyboard Shortcuts to set this to F11 globally would override custom behaviour from some programs. I've not found any examples of this, though. This would be easily extensible to disable the Emacs toolbar when fullscreen, for instance.
Posted: 09 Jul 2010 18:45 |
Flymake is an emacs minor mode that runs a syntax check tool over source files as you write them, on the fly. Essentially it calls the compiler for the relevant language and then parses the warnings.
Because this is so obviously useful, I have it turned on by default in .emacs:
; Highlight syntax errors (require 'flymake) (add-hook 'find-file-hook 'flymake-find-file-hook)
Recall also that I use emacs to view page source in Epiphany. Unfortunately, this produced a nasty dialog box warning about not being able to find an 'xml' command.
The solution comes in two parts:
;;;; xml-specific init-cleanup routines (defun flymake-xml-init () (list "xmlstarlet" (list "val" (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace))))
I suppose both emacs packages should really Suggest xmlstarlet - I wonder how many other external programs might fall into that category.
Posted: 21 Mar 2009 00:00 |
It turns out to be possible to persuade emacs and epiphany to play nicely together.
Sometimes Emacs presents you with clickable hyperlinks (in info documentation, perhaps).
To customize the browser in which these are opened, I am using the following in .emacs:
(setq browse-url-browser-function 'browse-url-generic browse-url-generic-program "gnome-open")
There are also specific epiphany-related functions, but I'm using the default gnome program for the moment. This can be configured via the default applications dialog.
When you download a text file, or use 'View > Page Source' in the menus, epiphany uses the gnome desktop's handler for the 'text/plain' mime type.
The simplest way of configuring this is to run nautilus, right-click on a text file and choose 'Properties'. Then the 'Open With' tab lets you select an application. Emacs should already be listed, or you can add it if not.
Posted: 23 Jan 2009 00:00 |
My attempt to learn to use emacs continues. Today's discovery: I can enable emacs-like keybindings in GTK text fields (well, Readline-like) - this includes form fields in Epiphany.
I have remapped C-w to backward-kill-word, to be more like Readline. I'm working up to writing some lisp to make common tasks easier... like writing blog entries, perhaps. I'll need to synchronize my .emacs files somehow... but I need to make more of an effort to use emacs over vim at work.
Posted: 07 Dec 2007 00:00 |
Three weeks ago I swapped capslock and Ctrl on all my usual systems, much to the chagrin of Daniel when he foolishly tried to use my keyboard. I'm now quite happy with the positioning of Ctrl - it was surprisingly easy to get used to.
It is not a coincidence that this is Tip #1 on various lists of ways to use emacs more effectively. I find myself wanting to ditch vim… perhaps this is just asking for a holy war.
My reasons are quite vague at the moment, but have something to do with wanting consistency of user interfaces across editor, shell and, er, IRC client. One other thing I've noticed is that very few people seem to write many vim macros - I suspect that having lisp to work with will actually make this easier. Also, of course, it's a GNU project! As part of that, the licensing is vastly more sensible than vim's.
So, seeing as forcing myself to use the capslock key as ctrl seemed to work, I suppose I'd better force myself to use emacs regularly instead of vim, and see how it goes. This involves purging vim from machines where I can, and aliasing 'vim' to 'emacs' in places I can't. Perhaps this will scare more people away from borrowing my keyboard.
Posted: 03 Dec 2007 00:00 |