Posts

Constraint Solving and Planning with Picat

I started reading a book Constraint Solving and Planning with Picat and found that there is no suitable mode for Picat in Emacs. There is only a basic mode from Reini Urban, which does not provide indentation and interaction with the Picat process. So I wrote my own version of picat-mode, which is somewhat more functional, although not perfect. It is available for free on github .

How to switch Safari's tooltips off

defaults write com.apple.Safari WebKitShowsURLsInToolTips 0

Force AppleMail to request mail recieve notifications

defaults write com.apple.mail UserHeaders '{"Disposition-Notification-To" = "Name@mail"; }'

sbcl-init.lisp

(setf (logical-pathname-translations "home") `(("**;*.*.*" ,(concatenate 'string (posix-getenv "HOME") "/**/*.*"))) (logical-pathname-translations "sbcl") `(("**;*.*.*" ,(logical-pathname "home:Library;sbcl;**;*.*"))) (logical-pathname-translations "src") `(("**;*.*.*" ,(logical-pathname "home:Src;**;*.*"))) (logical-pathname-translations "systems") `(("**;*.*.*" ,(logical-pathname "sbcl:systems;**;*.*")))) (require 'asdf) (setf asdf:*central-registry* '(#p"systems:")) (asdf:operate 'asdf:load-op 'asdf-install) (setf asdf-install:*locations* `((,(truename "systems:src") ,(truename "systems:") "SBCL specific installation")))

openmcl-init.lisp

(setf (logical-pathname-translations "src") `(("**;*.*.*" ,(logical-pathname "home:Src;**;*.*"))) (logical-pathname-translations "systems") `(("**;*.*.*" ,(logical-pathname "home:Library;CCL;systems;**;*.*")))) (load "ccl:tools;asdf.lisp") (setf asdf:*central-registry* '( *default-pathname-defaults* #p"systems:")) (asdf:operate 'asdf:load-op 'asdf-install) (setf asdf-install:*locations* `((,(truename "systems:src") ,(truename "systems:") "Personal installation")))

Map on lines in Emacs

;;;-------------------------------------------------------------------- (defun u:map-lines (beg end func) "Call given FUNC in the form (LAMBDA (LBEG LEND LSTR LCOUNT)...) for every line in the region. By default just print them." (interactive "r\nXMap Function ((LAMBDA (LSTR LBEG LEND LCOUNT) ...)): ") (let ((count 1) (inhibit-field-text-motion t)) (when (stringp func) (setq func (car (read (eval (concat "(" func ")")))))) (unless func (setq func #'(lambda (s b e c) (princ (format "%4d:%s" c s))))) (save-excursion (save-match-data (goto-char beg) (let (lbeg lend lstr (delta (- (point-max) end))) (while ( (setq lbeg (line-beginning-position 1)) (setq lend (line-beginning-position 2)) (setq lstr (buffer-substring-no-properties lbeg lend)) (funcall...

Loop on lines in emacs (version 1)

(defmacro do-lines (args &rest body) (let ((line (gensym "line-")) (beg (gensym "beg-")) (end (gensym "end-"))) `(let (,@args) (save-excursion (save-match-data (goto-char (point-min)) (while ( (setq ,beg (point)) (forward-line 1) (setq ,end (point)) (setq ,line (buffer-substring-no-properties ,beg ,end)) (setq ,(car args) ,line) (when ',(cdr args) (setq ,(cadr args) ,beg)) (when ',(cddr args) (setq ,(caddr args) ,end)) (progn ,@body))))))) (let (lines) (do-lines (l b e) (push (cons l e) lines)) (reverse lines))