The Shoes of the Fisherman's Wife Are Some Jive-Ass Slippers

tpot (at) frungy . org

rss

2008
Months
AugSep
Oct Nov Dec

Fri, 05 Jan 2007

Another Stevey Blog Rant About Emacs

Here. It's quite long and complicated. I wish I had time to write that much stuff about Emacs. Anyway, some choice quotes about whether you should learn Emacs Lisp:

"First, recognize that Emacs Lisp isn't going anywhere. Emacs is not going to magically become programmable in Python or Ruby or JavaScript or Perl overnight ... [Emacs Lisp] will never be obsolete knowledge. You might as well start learning it now, and reap the benefits now."

On Lisp syntax:

"If you do it enough, eventually you'll enjoy programming in Emacs-Lisp, no matter how much you hate it initially ... you'll initially dislike Emacs-Lisp's syntax; it's virtually guaranteed. Fortunately, it doesn't really have much in the way of syntax; almost everything follows the exact same s-expression form. So you should get past the syntax pretty quickly, and in a few weeks you'll start liking it just fine.
Kind of reminds me of people who dislike using tabs as syntax when writing Python code for the first time. I'm poking around with Ruby at the moment and having to put end everywhere is actually pretty annoying.

I've done some bits and pieces of Emacs Lisp programming over the years and it is quite seductive, for lack of a better word. I think that's the nature of functional programming though once you really get in to it.

posted at: 12:06 | path: /software/emacs | permanent link to this entry

Tue, 26 Sep 2006

agulbra-switch-cpp-h

I was thinking the other day that my life would be so much better if I could be editing a C++ file in Emacs and by simply hitting a key, the header for that file would be loaded. Hitting the key again would swap back from the header to the implementation. Before breaking out the Emacs Lisp manual I did a quick search and it turns out that those crazy kids at KDE have such a function in their kde-devel-emacs.el file.

Copy this bit of elisp somewhere and bind it to a key:

; From kde-devel-emacs.el, by by David Faure <faure@kde.org>

(defun agulbra-switch-cpp-h ()
  "Switch to the corresponding .cpp, .C, .cc or .h file."
  (interactive)
  (let ((n (buffer-file-name))
        (c nil))
    (cond ((and (string-match "\\.h$" n)
                (progn
                  (setq c (replace-match ".cpp" t t n))
                  (file-readable-p c)))
           (find-file c))
          ((and (string-match "\\.h$" n)
                (progn
                  (setq c (replace-match ".cc" t t n))
                  (file-readable-p c)))
           (find-file c))
          ((and (string-match "\\.h$" n)
                (progn
                  (setq c (replace-match ".C" t t n))
                  (file-readable-p c)))
           (find-file c))
          ((string-match "\\.h$" n)
           (find-file (replace-match ".cpp" t t n)))
          ((string-match "\\.h$" n)
           (find-file (replace-match ".cpp" t t n)))
          ;((string-match "_[a-z]+[0-9]*.cpp$" n)
          ; (find-file (replace-match ".h" t t n)))
          ((string-match "\\.cpp$" n)
           (find-file (replace-match ".h" t t n)))
          ((string-match "\\.cc$" n)
           (find-file (replace-match ".h" t t n)))
          ((string-match "\\.c$" n)
           (find-file (replace-match ".h" t t n)))
          (t
           (error "%s is neither .h, .cc, .C or .cpp" n)))))

posted at: 17:35 | path: /software/emacs | permanent link to this entry

Mon, 09 Aug 2004

Cool emacs Hack

(defun indent-or-complete ()
  "Complete if point is at end of a word, otherwise indent line."
  (interactive)
  (if (looking-at "\\>")
      (dabbrev-expand nil)
    (indent-for-tab-command)
    ))
 
(add-hook 'c-mode-common-hook
          (function (lambda ()
                      (local-set-key (kbd "") 'indent-or-complete)
                      )))
I think I'll try it out for a week or so and see how funky it is. posted at: 12:33 | path: /software/emacs | permanent link to this entry