Category Archives: pimpmyemacs

Excited about my DemoCamp presentation!

I’ve written a totally small-time presentation thingy that cues me thanks to Emacspeak. ;) Here’s the setup code:

(progn ;; Setup
  (defvar democamp/presentation-file "~/democamp.el")
  (defvar democamp/cue-buffer "*DemoCamp*")
  (defun democamp/next ()
    (let (start sexp)
      (with-current-buffer (find-file-noselect democamp/presentation-file)
        (setq start (point))
        (setq sexp (buffer-substring-no-properties start (point))))
      (eval (read sexp))))

  (defun democamp/previous ()
    (let (start sexp)
      (with-current-buffer (find-file-noselect democamp/presentation-file)
        (setq start (point))
        (setq sexp (buffer-substring-no-properties (point) start)))
      (eval (read sexp))))

  (defun democamp/repeat ()
    (let (start sexp)
      (with-current-buffer (find-file-noselect democamp/presentation-file)
        (setq start (point))
        (setq sexp (buffer-substring (point) start))
      (eval (read sexp))))

  (defun democamp/say (text)
    (with-current-buffer (get-buffer-create democamp/cue-buffer)
      (insert text)
      (goto-char (point-min))
      (call-interactively 'emacspeak-speak-buffer)))
  (global-set-key (kbd "") 'democamp/next)
  (global-set-key (kbd "S-") 'democamp/previous)
  (global-set-key (kbd "C-") 'democamp/repeat)

On Technorati: , ,

Random Emacs symbol: gnus-multiple-choice – Function: Ask user a multiple choice question.

Emacs and a British voice

There’s something about deep, deep cultural programming. Anything
spoken with a British accent just sounds infinitely cool. Everyone
uses the default voice for Asterisk and all of that – an American

You want to install festvox-rablpc16k or festvox-rablpc8k in addition
to all the usual things you need for emacspeak. You’ll also need
espeakf from CVS.

cvs login
cvs -z3 co -P espeakf
cd espeakf
sudo make install

One of these lines is responsible for setting up espeakf. I just can’t
be bothered with figuring out which. ;) Probably the dtk-program line.

(setq dtk-program "/usr/share/emacs/site-lisp/emacspeak/servers/")
(setenv "DTK_TCL" dtk-program)
(setenv "DTK_PROGRAM" dtk-program)

Then add this to your /etc/festival.scm:

(set! voice_default 'voice_rab_diphone)

Yummy British accent goodness.

On Technorati: , ,

Random Emacs symbol: mail-extr-disable-voodoo – Variable: *If it is a regexp, names matching it will never be modified.

Emacs: Quick way to collect references

(defvar sacha/planner-collector-buffer nil "Buffer for collecting links.")
(defun sacha/planner-collect-reference ()
  (let ((text (sacha/yank-blog-reference-for-summary)))
    (with-current-buffer sacha/planner-collector-buffer
      (insert text))))

(defun sacha/planner-collect-reference ()
  (let ((text (buffer-substring (line-beginning-position)
                                (1+ (line-end-position)))))
    (with-current-buffer sacha/planner-collector-buffer
      (insert text))))

On Technorati: ,

Random Emacs symbol: sgml-tag – Command: Prompt for a tag and insert it, optionally with attributes.

Emacs: Hideshow

One of the things I love about vising #emacs is that helping people with their questions lets me discover all sorts of cool things about Emacs. Today’s nugget? hideshow.el, which allows you to automatically hide / show code. (Equivalent of vim folding).

I’ve added the following code to my config:

(load-library "hideshow")
(add-hook 'emacs-lisp-mode-hook
          (lambda () (hs-minor-mode 1)
            (set (make-variable-buffer-local 'my-hs-hide) t)))
(defvar my-hs-hide t "Current state of hideshow for toggling all.")
(defun my-toggle-hideshow-all ()
  "Toggle hideshow all."
  (set (make-variable-buffer-local 'my-hs-hide) (not my-hs-hide))
  (if my-hs-hide
(global-set-key (kbd "C-c @ @") 'my-toggle-hideshow-all)
(global-set-key (kbd "C-c @ h") 'hs-hide-block)
(global-set-key (kbd "C-c @ s") 'hs-show-block)
(global-set-key (kbd "C-c @ SPC") 'hs-show-block)


… and then I find that I already have a
hideshow config, of course, and that
I added it on 2003.11.21… <bonk>!

On Technorati: ,

Random Emacs symbol: timezone-parse-date – Function: Parse DATE and return a vector [YEAR MONTH DAY TIME TIMEZONE].

Emacs Gnus hack: Prioritize based on the number of recipients

Ever found yourself confronted with an inbox overflowing with general
messages that you can ignore and messages that you and only you can
act on? Here’s something to help you sort the wheat from the chaff.

This indicates how personal messages are so you can immediately see which messages are just for you and which are part of a long Cc. Stephen Perelgut showed me the feature in Lotus Notes and I wanted to steal it sometime, so I did it while waiting for the Instant Rails archive.

To use it, add %ur to your gnus-summary-line-format.

(add-to-list 'nnmail-extra-headers 'To)
(add-to-list 'nnmail-extra-headers 'Cc)
(defvar sacha/gnus-count-recipients-threshold 5
  "*Number of recipients to consider as large.")

(defun sacha/gnus-count-recipients (header)
  "Given a Gnus message header, returns priority mark.
If I am the only recipient, return \"!\".
If I am one of a few recipients, but I'm listed in To:, return \"*\".
If I am one of a few recipients, return \"/\".
If I am one of many recipients, return \".\".
Else, return \" \"."
  (let* ((to (or (cdr (assoc 'To (mail-header-extra header))) ""))
         (cc (or (cdr (assoc 'Cc (mail-header-extra header))) "")))
     ((string-match gnus-ignored-from-addresses to)
      (let ((len (length (bbdb-split to ","))))
         ((= len 1) "!")
         ((< len sacha/gnus-count-recipients-threshold) "*")
         (t "/"))))
     ((string-match gnus-ignored-from-addresses
                    (concat to ", " cc))
      (if (< (length (bbdb-split (concat to ", " cc) ","))
     (t " "))))

(defalias 'gnus-user-format-function-r 'sacha/gnus-count-recipients)

Random Emacs symbol: dired-listing-switches - Variable: *Switches passed to `ls' for Dired. MUST contain the `l' option.

On Technorati: , , ,

Developing a better sense of time

One of the things I want to do is develop a good sense of how long it
takes me to do something. Better time estimates lead to better
scheduling, better sense of what I can commit to, and ultimately less
stress and more happiness. =)

Fortunately, Planner makes it easy for me to do really detailed
time-tracking. When I mark a task as in progress, the clock starts
ticking. When I postpone or close a task, the system clocks out

I find that my attention occasionally strays. Sometime ago, I wrote a
function to help me keep track of what I’m supposed to be doing.
Today, I’ve decided to try estimating task completion times for more
of the tasks on my list. I modified my old function to tell me how
much time has elapsed since I started the task. This doesn’t take into
account previous clock-in/clock-outs, but it will do for now.

We’ll see how well it works. =)

;; I've bound sacha/planner-what-am-i-supposed-to-be-doing to F9 F11. I
;; start out by clocking into the task (use planner-timeclock.el and
;; C-c TAB to mark a task as in progress). Then, when I find myself
;; getting distracted, I hit F9 F9 to see my current task in the
;; minibuffer. C-u F9 F9 jumps back to the task so that I can either
;; mark it as postponed. M-x planner-task-pending (bound to C-c C-p in
;; my local config) and M-x planner-task-done (C-c C-x) both clock out
;; of the task. If I want to jump back to the previous window
;; configuration from that planner page, I can just hit F9 F9 again.

(defvar sacha/window-register "w"
  "Register for jumping back and forth between planner and wherever I am.")
(defvar sacha/planner-current-task nil
  "Current task info.")
(defadvice planner-task-in-progress (after sacha activate)
  "Keep track of the task info."
  (setq sacha/planner-current-task (planner-current-task-info)))

(defun sacha/planner-what-am-i-supposed-to-be-doing (&optional prefix)
  "Make it easy to keep track of what I'm supposed to be working on.
If PREFIX is non-nil, jump to the current task, else display it
in a message. If called from the plan page, jump back to whatever
I was looking at."
  (interactive "P")
  (if planner-timeclock-current-task
      (if (string= (planner-task-page sacha/planner-current-task)
          (jump-to-register sacha/window-register)
        (if (null prefix)
            (message "%s %s"
                     ;; Minutes so far
                     (timeclock-seconds-to-string (timeclock-last-period))
          (frame-configuration-to-register sacha/window-register)
          (planner-find-file (planner-task-page sacha/planner-current-task))
          (planner-find-task sacha/planner-current-task)))
    (if prefix
      (message "No current task. HEY!"))))

On Technorati: , , ,

Random Emacs symbol: cal-tex-mouse-filofax-week – Command: Two page Filofax calendar for week indicated by cursor. (Hey, I didn’t know we could print Filofax calendars from Emacs cal…)