Friday, April 15, 2011

Tuesday, April 12, 2011

Another Emacs plugin: highlight-symbol

I guess, it is a must.



C-f3 - highlight-symbol-at-point
  f3 - highlight-symbol-next
S-f3 - highlight-symbol-prev
M-f3 - highlight-symbol-prev

Tuesday, April 5, 2011

On Switching Window Configurations in Emacs

I missed the stability in Emacs' layouts. In short, ESC ESC ESC command could break current layout. It was annoying. I missed some fixer to make my Emacs usable. I looked for it for a long time and finally found it: Windows And Registers. Also, the section Switching Window Configurations is interesting.

Short description:
  • C-x r w – stores the current configuration in a register
  • C-x r j – restores the configuration from a register
Example:
  • C-x r w 1 – store the current configuration
  • C-x 2 – split vertically
  • C-x 3 – split horizontally
  • C-x r j 1 – restore the stored window configuration

Saturday, March 12, 2011

LispCabinet, again.

The SBCL seems to be not good enough to fight with errors in Lisp code.
CLISP, ClozureCL can be of greater help in this case.

Exactly for this reason I installed LispCabinet with all available CL's in it at the moment: SBCL, CLISP, ClozureCL, ABCL, ECL. I used not portable but the regular installation that uses the "HOME" environment variable. This made it possible to remove a lot of manual configurations.

All manual changes are as follows:

  1. I place my code in ~/lisp/development/ folder.
  2. I added the file auto-indent-mode.el to ~/.emacs.d/ folder.
  3. I put (add-to-list 'load-path "~/.emacs.d/") into the .emacs file.

That's all!

But the road to this solution was bumpy...

Wednesday, February 23, 2011

Lisp on Windows

Here is the description of the easiest (from my point of view) way of using Common Lisp on Windows, current version.


Unfortunately, it is impossible just to install everything, some additional tricks are necessary.

Here is the recipe:
  1. Install LispCabinet, SBCL version. I use "portable" installation. The only difference from usual one is that "portable" version does not use registry and does not use environment variables (I hope. I did not check!).
  2. Download the auto-indent-mode.el into LispCabinet\cabinet\site\.emacs.d\
    Well, I am not 100% sure in the path, but I hope it is right. Anyway, place the file in the folder where Emacs can find it.
  3. Add the following code into asdf-init.lisp (please find the file yourself. And sorry for absolute paths):
    (format t "-------------------------------- START --------------------------------~%")
    
     (defvar *lisp-dirs* "d:/Paul.revised/git.repos/github/")
    
    (dolist (dir-candidate (directory (concatenate 'string *lisp-dirs* "*/")))
      (let ((asd-candidate (merge-pathnames "*.asd" dir-candidate)))
        (when (and (directory dir-candidate)
                   (not (member (namestring dir-candidate)
                                (mapcar #'(lambda (x)
                                                  (when (pathnamep x)
                                                  (namestring x)))
                                        asdf:*central-registry*)
                                :test #'equal)))
              (progn
                  (format t "PUSHED directory: ~a~%" dir-candidate)
                  (pushnew dir-candidate asdf:*central-registry*)))))
    
    (format t "--------------------------------- END ---------------------------------~%")
  4. Here is .emacs file. Use it as it is or take any part of it. Before using it please execute "M-x package-list-packages" and install at least paren-mode and highlight-parentheses-mode:
    ;; A lot of settings are taken from the site http://rigidus.ru/articles
    
    
    (custom-set-variables
     ;; custom-set-variables was added by Custom.
     ;; If you edit it by hand, you could mess it up, so be careful.
     ;; Your init file should contain only one such instance.
     ;; If there is more than one, they won't work right.
     '(column-number-mode t)
     '(glasses-face (quote default))
     '(hl-paren-colors (quote ("MediumSpringGreen" "red1"
                               "DodgerBlue" "yellow1" "magenta"
                               "orange1" "orange4")))
     '(indent-tabs-mode nil)
     '(scroll-bar-mode nil))
    
    (custom-set-faces
     ;; custom-set-faces was added by Custom.
     ;; If you edit it by hand, you could mess it up, so be careful.
     ;; Your init file should contain only one such instance.
     ;; If there is more than one, they won't work right.
     '(hl-paren-face ((t (:foreground "gray35"))) t))
    
    (defface paren-face
      '((((class color) (background dark))
         (:foreground "grey35"))
        (((class color) (background light))
         (:foreground "grey80")))
      "Face used to dim parentheses.")
    
    (defun parenhook ()
      (font-lock-add-keywords nil '(("(\\|)" . 'paren-face))))
    
    (add-hook 'emacs-lisp-mode-hook
        (lambda () (paredit-mode +1)))
    (add-hook 'lisp-mode-hook
        (lambda () (paredit-mode +1)))
    (add-hook 'lisp-interaction-mode-hook
        (lambda () (paredit-mode +1)))
    
    (add-hook 'emacs-lisp-mode-hook #'parenhook)
    (add-hook 'lisp-mode-hook #'parenhook)
    (add-hook 'slime-lisp-mode-hook #'parenhook)
    (add-hook 'inferior-lisp-mode-hook #'parenhook)
    
    (require 'highlight-parentheses)
    (add-hook 'lisp-mode-hook (highlight-parentheses-mode))
    (define-globalized-minor-mode global-highlight-parentheses-mode
      highlight-parentheses-mode highlight-parentheses-mode)
    
    (global-highlight-parentheses-mode)
    
    (autoload 'paredit-mode "paredit"
      "Minor mode for pseudo-structurally editing Lisp code." t)
    ;; Comment function
    (defun comment-or-uncomment-this (&optional lines)
      (interactive "P")
      (if mark-active
          (if (< (mark) (point))
              (comment-or-uncomment-region (mark) (point))
            (comment-or-uncomment-region (point) (mark)))
        (comment-or-uncomment-region
         (line-beginning-position)
         (line-end-position lines))))
    
    (global-set-key (kbd "C-;") 'comment-or-uncomment-this)
    
    (defun save-point-and-switch ()
      "Save current point to register 0 and go
    to the previously saved position"
      (interactive)
      (let (temp)
        (setq temp (point-marker))
        (when (not (equal (get-register 0) nil))
          (jump-to-register 0))
        (set-register 0 temp)))
    
    (global-set-key (kbd "\e\e/") 'save-point-and-switch)
    (global-set-key (kbd "\e\e?") 'save-point-only)
    
    (color-theme-zenburn)
    
    (require 'auto-complete-config)
    (ac-config-default)
    
    (setq auto-indent-on-visit-file t)
    (require 'auto-indent-mode)
    (auto-indent-global-mode)
    
  5. Download Quicklisp and follow instructions. It just works. Somehow...

Monday, December 13, 2010

Emacs: missing paredit and zenburn. Solution: ELPA.

To have the functionality of the paredit, zenburn and other extensions of the Emacs, there is an easy way to add them to the Lisp Cabinet. Just use ELPA, which is available in the Lisp Cabinet already.

So do following steps:
"...type  M-x package-list-packages. Type r in the package menu buffer to update the list of packages available from the server. If you want a particular package, type i next to its name to mark it for installation, and then x to download and install it."

Windows: Lisp Cabinet, Quicklisp, Lispbuilder-SDL.

There are many ways to provide Lispbuilder-SDL on Windows platform for SBCL.
I present the simplest one I found.

  1. Install Lisp cabinet. I installed SBCL version only.
  2. Run it (choose SBCL version in the dialog) and in SBCL REPL run the command (lisp-cabinet:load-quicklisp)
  3. Now we have almost everything done and the only lacking part is the Lispbuilder-SDL itself. To install it:
    1. Get the runtime of SDL library and put SDL.dll file, say, to C:\WINDOWS\ folder.
    2. Install the Lispbuilder-SDL with the following command in REPL: (ql:quickload "lispbuilder-sdl")


VoilĂ .

My Blog List