Tuesday, December 30, 2008

To load ASDF-modules by using REQUIRE


;; Make it so we can load via ASDF just by using REQUIRE (I'm lazy)
;; mostly stolen from http://www.mail-archive.com/cmucl-help-bounce@cons.org/msg02514.html
(defun module-provide-asdf (name)
(let* ((name (string-downcase name))
(system (asdf:find-system name nil)))
(when system
(asdf:oos 'asdf:load-op name)
t)))

;; hook it in
(pushnew 'module-provide-asdf *module-provider-functions*)

Sunday, December 7, 2008

Create DMG from Finder folder

1. In Disk Utility: File->New->Disk Image From Folder... --> create read-write image
2. Mount the image
3. Customize the folder [1]
4 In Disk Utility: Images->Convert->Compressed (bzip2) [2]

[1] Create a hidden folder in the DMG-ed folder (.background). Put there an image. With Cmd-J (Show View Options) open View Options panel for the folder and select the image as a background to use.

[2] ?

Better indentation for Common Lisp in Emacs

Use CLISP-INDENT from CLisp.

Saturday, December 6, 2008

Objective-C debugging tips

1. Run app from console with OBJC_HELP environment variable set to 1.
2. Set NSObjCMessageLoggingEnabled env. variable to YES or call to instrumentObjcMessageSends(YES) to log all Objective-C messages.

(Got from Dave Dribin's Blog)

Sunday, October 12, 2008

Emacs has extended column editing support through its CUA-MODE (Common User Access). To activate it one should put these lines in his .emacs file:

(setq cua-enable-cua-keys nil)
(setq cua-highlight-region-shift-only nil) ;; no transient mark mode
(setq cua-toggle-set-mark nil) ;; original set-mark behavior, i.e. no transient-mark-mode
(cua-mode)


(Taken from LIFE IS TOO SHORT FOR BAD CODE)

Tuesday, September 30, 2008

Customize PAREDIT

I love PAREDIT on the whole, but hate the default behavior of ';' and ')'. So here how to fix this and made PAREDIT slightly less aggressive (should be added into the ~/.emacs file):

(require 'paredit)
(eval-after-load 'paredit
'(progn
(define-key paredit-mode-map (kbd ";") 'self-insert-command)
(define-key paredit-mode-map (kbd ")") 'paredit-close-parenthesis)
(define-key paredit-mode-map (kbd "M-)") 'paredit-close-parenthesis-and-newline)))

Monday, September 29, 2008

SBCL and default location for ASDF-INSTALL

To make asdf-install find default location in sbcl:
(fmakunbound 'asdf-install::where)
(defun asdf-install::where ()
(first asdf-install::*locations*))

This tip's been given by xach

Monday, August 11, 2008

Remove duplicated lines in region


(defun u:remove-duplicates (beg end)
(interactive "r")

(let* ((str (mapconcat 'identity
(remove-duplicates
(split-string (buffer-substring beg end) "[\n\r]+" t)
:test 'string=)
"\n")))

(delete-region beg end)
(insert str)))

Updated u:load-alternative


(defvar u:*dir-delim* "/")
(defvar u:*sfile-exts* '("mm" "m" "cpp" "cp" "c" ))

;; LOAD HEADER FROM SOURCE AND VICE VERSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun u:load-alternate ()
(interactive)
(let ((fname (buffer-file-name))
(templ (format "\\(.*%s\\)?\\(\\(.*?\\)_\\(.*\\)\\|\\(.*\\)\\)\\.\\(.*\\)" u:*dir-delim*)))

(when (string-match templ fname)
(let* ((dir (match-string 1 fname))
(nam1 (match-string 3 fname))
(nam2 (match-string 4 fname))
(nam0 (or (match-string 5 fname)
(match-string 2 fname)))
(ext (match-string 6 fname))

(fname (cond
((member ext u:*sfile-exts*)
(dolist (name (list nam0 nam1))
(let ((fname (if dir
(format "%s%s.h" dir name)
(format "%s.h" name))))

(when (file-readable-p fname)
(return fname)))))

((string-equal ext "h")
(dolist (ext u:*sfile-exts*)
(let ((fname (if dir
(format "%s%s.%s" dir nam0 ext)
(format "%s.%s" nam0 ext))))
(when (file-readable-p fname)
(return fname))))))))

(when fname (find-file fname))))))

Thursday, August 7, 2008

Wednesday, June 4, 2008

Set Leopard's Help Viewer to behave like Tiger's one

To switch off 'floating window' behavior:

defaults write com.apple.helpviewer NormalWindow -bool true


To turn it in a normal application:

i=/System/Library/CoreServices/"Help Viewer.app"/Contents/Info.plist
sudo defaults write "${i%.plist}" LSUIElement 0
sudo chmod 644 "$i"

Monday, April 14, 2008

How to build Carbon Emacs


./configure --without-x --enable-carbon-app=/Applications --prefix=/Applications/Emacs.app/Contents/Resources/emacs/ --without-toolkit-scroll-bars
make
sudo make install

That's all folks!

Tuesday, March 25, 2008

Set Shift-delete to put text in clipboard in Emacs

(global-set-key [S-delete] 'clipboard-kill-region)

Thursday, March 20, 2008

PC-like select/delete in Emacs


;; Conventional selection/deletion
(require 'pc-select)
(setq pc-select-selection-keys-only t)
(pc-selection-mode)
(delete-selection-mode t)

Monday, March 17, 2008

Using org.gnu.Emacs.plist to tune Emacs.app


Emacs.lineSpacing Number 2
Emacs.toolBar Boolean NO

Monday, February 4, 2008

Setup ruby-mode in Emacs

From DIGITAL SANITATION ENGINEERING:
1. Got ruby-mode.el:
svn export http://svn.ruby-lang.org/repos/ruby/trunk/misc  elisp/ruby

2. compile:

cd elisp/ruby
emacs -batch -f batch-byte-compile ./

3. Add to Emacs init file:

(add-to-list 'load-path (concat u:*elisp* "ruby/"))

(autoload 'ruby-mode "ruby-mode"
"Mode for editing ruby source files")

(add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
(add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode))

(autoload 'run-ruby "inf-ruby"
"Run an inferior Ruby process")

(autoload 'inf-ruby-keys "inf-ruby"
"Set local key defs for inf-ruby in ruby-mode")

(add-hook 'ruby-mode-hook
'(lambda ()
(inf-ruby-keys)))

;; If you have Emacs 19.2x or older, use rubydb2x
(autoload 'rubydb "rubydb3x" "Ruby debugger" t)
;; uncomment the next line if you want syntax highlighting
(add-hook 'ruby-mode-hook 'turn-on-font-lock)

Thursday, January 31, 2008

Enable recursive delete in Emacs DIRED mode


(setq dired-recursive-deletes 'top
dired-recursive-copies 'top)

Sunday, January 13, 2008

Parenface Emacs Mode

To make parentheses look better setup PARENFACE.EL and the following lines to .emacs:

(require 'parenface)
(set-face-foreground 'paren-face "SteelBlue")

To make editing lisp more structured use PAREDIT:

(require 'paredit)
(add-hook 'emacs-lisp-mode-hook (lambda () (paredit-mode +1)))
(add-hook 'lisp-mode-hook (lambda () (paredit-mode +1)))
(add-hook 'inferior-lisp-mode-hook (lambda () (paredit-mode +1)))
(add-hook 'slime-repl-mode-hook (lambda () (paredit-mode +1)))