28 Feb

Open in new tab in running Carbon Emacs

Wednesday February 28th 2007, 12:13 pm
Tags: , , ,

Carbon Emacs acts like emacsclient or gnuserv by itself, i.e. it only runs one instance and opens files in this instance from Finder automatically.

A drawback of this behaviour is that the usual server-window variable of gnuserv has no effect. When using elscreen to get tabs into Emacs the desired behaviour might be to open a new tab in the running Emacs when you open a file from Finder. This can easily be done, using my intelligent-kill command (see my elscreen posting) such that files from Finder are opened in a new tab, and you can close this tab with the usual C-x C-c:

(defun create-new-tab-and-switch-to ()
  (message "New tab")
  (elscreen-create))

(defadvice mac-ae-open-documents (before mac-ae-open-documents-advice activate)
  "Create new tab before" (create-new-tab-and-switch-to))
(ad-activate ‘mac-ae-open-documents)

0 Comments

30 Dec

One of those “How could I live without” tools

Saturday December 30th 2006, 12:16 am
Tags: ,

So useful that I just have to cite it here again from metashell blog:

Another incredibly useful package is mcomplete.el, which performs parital or fuzzy completion based on prefix and substring matching, with hints. It’s basically a run-time apropos command that runs in the minibuffer and really helps when you can’t quite remember what command or buffer you wanted and could use a few suggestions. It’s a bit hard to describe how it helps, but once I started using it, I think I would find it very hard to go back. Put the following into your ~/.emacs after downloading mcomplete.el to ~/.elisp:
(require ‘mcomplete)
(mcomplete-mode t)
0 Comments

11 Dec

Server password for rcirc.el

Monday December 11th 2006, 2:16 pm
Tags: , ,

A working patch against
rcirc.el from
Emacs CVS revision 1.30 to add support for server authentification. The
original patch from
http://www.emacswiki.org/cgi-bin/wiki/rcircServerAuth were broken and
moreover had several errors anyway.

? rcirc-pass.el.patch
Index: rcirc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/net/rcirc.el,v
retrieving revision 1.30
diff -u -p -B -w -u -r1.30 rcirc.el
— rcirc.el    24 Nov 2006 10:33:22 -0000  1.30
+++ rcirc.el    11 Dec 2006 12:59:37 -0000
@@ -153,18 +153,20 @@ the window."
 Each element of the list is a list with a SERVER-REGEXP string
 and a method symbol followed by method specific arguments.

-The valid METHOD symbols are `nickserv’, `chanserv’ and
+The valid METHOD symbols are `nickserv’, `chanserv’,’server’ and
 `bitlbee’.

 The required ARGUMENTS for each METHOD symbol are:
   `nickserv’: NICK PASSWORD
   `chanserv’: NICK CHANNEL PASSWORD
   `bitlbee’: NICK PASSWORD
+  ’server’: NICK PASSWORD

 Example:
  ((\"freenode\" nickserv \"bob\" \"p455w0rd\")
   (\"freenode\" chanserv \"bob\" \"#bobland\" \"passwd99\")
-  (\"bitlbee\" bitlbee \"robert\" \"sekrit\"))"
(\"bitlbee\" bitlbee \"robert\" \"sekrit\")
+  (\"ctrlproxy\" server \"bob\" \"secret\"))"

   :type(alist :key-type (string :tag "Server")
               :value-type (choice (list :tag "NickServ"
                                      (const nickserv)
@@ -178,6 +180,10 @@ Example:
                                 (list :tag "BitlBee"
                                      (const bitlbee)
                                      (string :tag "Nick")
+                                     (string :tag "Password"))
+                                (list :tag "Server"
+                                     (const server)
+                                     (string :tag "Nick")
                                      (string :tag "Password"))))
   :group ‘rcirc)

@@ -397,6 +403,9 @@ If ARG is non-nil, prompt for a server t
       (make-local-variable ‘rcirc-last-server-message-time)
       (setq rcirc-last-server-message-time (current-time))

+      ;; send password before NICK command if available
+      (rcirc-authenticate)
+
       ;; identify
       (rcirc-send-string process (concat "NICK " nick))
       (rcirc-send-string process (concat "USER " user-name
@@ -2268,6 +2277,11 @@ Passwords are stored in `rcirc-authinfo’
                (rcirc-send-string
                 process
                 (concat "PRIVMSG &bitlbee :identify " (car args))))
+                ((equal method ’server)
+                 (message "Sending PASS command to %s" server)
+                 (rcirc-send-string
+                  process
+                  (concat "PASS " (car args))))
               (t
                (message "No %S authentication method defined"
                        method))))))))

0 Comments

07 Dec

You should byte-compile XYZ

Thursday December 07th 2006, 11:24 pm
Tags: , ,

Sure, without much trouble using jhg-cload.el and the following snippet to make compiling a bit smarter: store the .elc in ~/.elc and avoid recompiling, especially if there were errors before. Normally there is no sense to try it again and again:

(require ‘jhg-cload)
(setq load-path (cons "~/.elc" load-path))
(defun jhg-cload-compile (file)
  "Compile FILE if it is ok and out of date."
  (let* ((file-name (locate-library file))
         (path-base (file-name-sans-extension file-name))
         (path-el   (concat path-base ".el"))
         (path-elc-before (concat path-base ".elc"))
         (path-elc  (concat "~/.elc/"
                            (file-name-sans-extension
                             (file-name-nondirectory file-name))
                            ".elc"))
         (path-elc-error (concat path-elc "-error")))
    (if (and (jhg-cload-oktocompile-p path-base)
             (not (file-exists-p path-elc-error)))
      (if (file-newer-than-file-p path-el path-elc)
        (progn
          ;; remove the old file — viano and linux disagree over gids
          (condition-case nil (make-directory elc-dir) (error nil))
          (condition-case nil (delete-file path-elc) (error nil))
          (condition-case nil (delete-file path-elc-before) (error nil))
          ;; set about compiling it
          (jhg-cload-msg 1 "cload: compiling ‘%s’…" path-el)
          (save-excursion (write-region (point-min) (point-min) path-elc-error))
          (byte-compile-file path-el)
          (when (file-exists-p path-elc-before)
            (rename-file path-elc-before path-elc)
            (delete-file path-elc-error)
            (jhg-cload-msg 2 "cload: ok ‘%s’" file)))
      (jhg-cload-msg 2 "cload: skipping ‘%s’…" file)))))
0 Comments

05 Dec

Wide screen code

Tuesday December 05th 2006, 12:13 pm
Tags: ,

Self explaining function names. From proof-script.el of ProofGeneral.

0 Comments

03 Dec

Note for next time EmacsW32 does not work

Sunday December 03rd 2006, 4:38 pm
Tags: , ,

If you are trying to use the EmacsW32 package, a packaged NTEmacs with a nice installer and some patches like emacsclient support, and it doesn’t startup at all, consider to remove the registry entries in HKCU/Software/GNU/Emacs. If you have set some paths pointing to an old Emacs there, it will confuse EmacsW32 and make it give strange error messages in CMD.exe like “Cannot open load file: code-pages“. Cleaning the registry fiest can save your Sunday afternoon.

0 Comments