Emacs


The macports version of emacs 22.1_1 (no x11, no carbon) is broken. I use it. Fortunately, Yamamoto Mitsuharu’s patch http://article.gmane.org/gmane.emacs.bugs/16867 allows it to build and install on Leopard x86. The bug tracker has Ticket #13942 for 1.6 and Ticket #13471 for 1.5.2 that have not been acknowledged by the maintainer.

Seems to work so I’ve slapped together a patch file and a portfile to use it until the fixes get incorporated:

Great idea and public doman code from Michele Bini for tying the Emacs calculator into hippie expand.

Filladapt mode is good but the Perl module Text::Autoformat is better at reflowing text for email. I cobbled together the following elisp to make that easy.

(defun rel-autoformatter (begin end rightmargin)
  "Run Text::Autoformat on region"
  (shell-command-on-region begin end
   (format "perl -MText::Autoformat -e 'autoformat({all=>1,right=>%d})'" rightmargin) t t )
  (message "done."))

(defun rel-autoformat (begin end)
  Text::Autoformat on region, RFC recommended right margin of 72"
  (interactive "r")
  (rel-autoformatter begin end 72))

(defun rel-autoformat-quote (begin end)
  "Text::Autoformat on region, right margin of 60, suitable for quoting replies"
  (interactive "r")
  (rel-autoformatter begin end 60))

(global-set-key (kbd "C-c f f") 'rel-autoformat)
(global-set-key (kbd "C-c f q") 'rel-autoformat-quote)

It might be nice to handle parameters other than right margin- and do it in a cleaner way than explicitly specifying them. I doubt I’ll get around to it since Text::Autoformat usually does the right thing for me with just the margin hint.

I get a lot of email at work and at home and I’m always deleting sections and inlining responses so I decided that I needed a key binding in XEmacs to do that work for me. Thanks to my growing familiarity with Scheme, writing elisp doesn’t seem so bad (well, as long as I have the XEmacs Lisp Reference Manual handy).

It’s ugly but it works and it’s my first useful creation in Lisp/Scheme:

(defun region-is-active ()           ;; stolen from eparker's dot file
  (if (string-match "XEmacs" emacs-version)
      (region-exists-p)  mark-active) ) 

(defun whack () "text killer, region, to sig, or next paragraph"
       (interactive)
       (let ((start (point)))
         (cond 
          ((region-is-active) (delete-region (point) (mark)))
          ((re-search-forward "^--" nil t) 
            (forward-line -1) (delete-region start (point)))
          (t (forward-paragraph) (delete-region start (point)))))
       (insert "    [snip]\n\n\n")
       (forward-line -1))

(global-set-key (kbd "C-x !") 'whack)

YetAnotherPersonalHomepage is proudly powered by WordPress
Entries (RSS) and Comments (RSS).
Original theme design by www.vanillamist.com.