Friday, October 21, 2011

Emacs or Ubuntu sucks.

I have a part in my dot-file that positions the Emacs window on the screen. It works on all OSes: Windows, OSX and linuxes. I use only Ubuntu for now and guess which OS puts the Emacs window on the screen incorrectly? Well, you can guess from the header of the post.

To implement the positioning, I used following link: How do I set the size of Emacs' window?
The code I have now is this:
(progn
  (set-frame-size (selected-frame) 146 39)
  (set-frame-position (selected-frame) 105 30))
Also I tried this:
(setq initial-frame-alist
 (append '((width . 135) (height . 55) (top . 15) (left . 140))
  initial-frame-alist))
Anyway, I don't get it - how it is possible to misplace the window on the screen so wrong. It blinks, jumps, resizes itself for few times and finally is placed more or less randomly on the screen.

I guess Ubuntu is not to blame. Maybe X server is, maybe Emacs itself.
But I don't care actually, should I?

Thursday, May 12, 2011

Finally got rid of tabbar and slime header line.

Last improvements are:
  • got rid of TABBAR and SLIME header line in REPL buffer, so I have less trash on the screen.
  • changed buffer switching to bs-show, which is more compact and sane
  • turned on IDO-mode, which is good for loading files
  • turned on autocomplete-mode everywhere
  • turned on highlight-symbol-mode everywhere
Here is the .emacs file:

Maybe later I would split it to different files and do something like Steve Yegge did.

Wednesday, April 20, 2011

Narrowing

Following commands seem to help very much.

In short, with "narrow" I leave only current defun in the buffer to edit, with "widen" I show complete file again.

C-x n d ...... Narrow down to the current defun (`narrow-to-defun').
C-x n w ...... Widen to make the entire buffer accessible again (`widen').

There are two more commands for region and page, but they are useless for me.
Anyway in Emacs' help one can find full description in the chapter called "Narrowing".

And yes, I added following three lines to my .emacs file to enable described functionality:
(put 'narrow-to-defun 'disabled nil)
(put 'narrow-to-page 'disabled nil)
(put 'narrow-to-region 'disabled nil)

Code folding

hs-minor-mode
show all ---------- C-c @ C-M-s
hide all ---------- C-c @ C-M-h
show block -------- C-c @ C-s
hide block -------- C-c @ C-h
toggle hide/show -- C-c @ C-c
toggle hide/show -- S-mouse-2

Another "a must": macros.

Here is a detailed description.

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...

My Blog List