15 July, 2008
31 May, 2008
About time I posted my new .emacs
;; Moving cursor down at bottom scrolls only a single line, not half page
(setq scroll-step 1)
(setq scroll-conservatively 5)
(global-set-key [delete] 'delete-char)
;; Every file has at least a new line
(setq require-final-newline t)
;;SLIME for lisp
(add-to-list 'load-path "/Users/mifa/lisp/slime-2.0/") ; your SLIME directory
(setq inferior-lisp-program "/usr/local/bin/sbcl") ; your Lisp system
(require 'slime)
(slime-setup)
;;something about bookmarks
(defun hk ()
(insert "(setq-default bookmark-default-file \"bookmarks\")\n"))
;; Make all "yes or no" prompts show "y or n" instead
(fset 'yes-or-no-p 'y-or-n-p)
;; Make scripts executable on Save (saves having to do the chmod every time)
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
;; set up Time Stamps
(add-hook 'before-save-hook 'time-stamp)
(add-to-list 'load-path "/Users/mifa/.emacs.d/")
(setq search-highlight t)
;; show current function in modeline
(which-func-mode t)
;; .emacs
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
;;(set-fringe-mode 0)
;; Before we start setting colors, we have to tell Emacs to always
;; syntax-hightlight everything to its fullest extent, and don't wait
;; to fontify (do it immediately).
;;
(highlight-changes-mode t)
(highlight-changes-mode t)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(setq font-lock-maximum-size nil)
(setq font-lock-support-mode 'jit-lock-mode)
(setq jit-lock-stealth-time 0)
;; uncomment this line to disable loading of "default.el" at startup
(setq inhibit-default-init t)
;; Highlight "FIXME" comments
(font-lock-add-keywords
'c++-mode
'(("\\<\\(FIXME\\)" 1 font-lock-warning-face t)))
(modify-face (quote font-lock-warning-face) "Red" "yellow" nil t nil t nil nil)
(font-lock-add-keywords
'c++-mode
'(("\\<\\(NOTE\\)" 1 font-lock-warning-face t)))
(modify-face (quote font-lock-warning-face) "Red" "yellow" nil t nil t nil nil)
(font-lock-add-keywords
'c++-mode
'(("\\<\\(POLARIZED\\)" 1 highlight t)))
(modify-face (quote font-lock-warning-face) "Red" "yellow" nil t nil t nil nil)
(font-lock-add-keywords
'c++-mode
'(("\\<\\(misha\\)" 1 highlight t)))
(modify-face (quote font-lock-warning-face) "Red" "yellow" nil t nil t nil nil)
(font-lock-add-keywords
'c++-mode
'(("\\<\\(UNPOLARIZED\\)" 1 highlight t)))
(modify-face (quote font-lock-warning-face) "Red" "yellow" nil t nil t nil nil)
(font-lock-add-keywords
'perl-mode
'(("\\<\\(FIXME\\)" 1 font-lock-warning-face t)))
(modify-face (quote font-lock-warning-face) "Red" "yellow" nil t nil t nil nil)
(font-lock-add-keywords
'perl-mode
'(("\\<\\(NOTE\\)" 1 font-lock-warning-face t)))
(modify-face (quote font-lock-warning-face) "Red" "yellow" nil t nil t nil nil)
(setq c++-font-lock-extra-types
'(
"TFile"
"TProfile" "TH1D" "TH1F" "TH1"
"Double_t" "Float_t" "Int_t"
) )
(transient-mark-mode t)
(eval-after-load "perl-mode"
'(define-key perl-mode-map "\C-c\C-c" 'comment-region))
;(eval-after-load "python-mode"
; '(define-key python-mode-map "\C-c\C-c" 'comment-region))
(show-paren-mode 1)
;; define function to match a parenthesis otherwise insert a '~'
(defun goto-match-paren (arg)
"Go to the matching parenthesis if on parenthesis otherwise insert '~'."
(interactive "p")
(cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
((looking-at "\\s\)") (forward-char 1) (backward-list 1))
(t (self-insert-command (or arg 1)))))
(global-set-key (kbd "~") 'goto-match-paren)
(global-set-key "\M-n" 'next-error)
(global-set-key "\M-p" 'previous-error)
(global-set-key "\C-c\C-f" 'highlight-changes-mode)
(global-set-key "\C-c\C-d" 'highlight-changes-rotate)
(global-set-key "\C-c\C-l" 'highlight-lines-matching-regexp)
(global-set-key "\C-c\C-r" 'highlight-regexp)
(global-set-key "\C-c\C-s" 'customize-save-customized)
;; turn on font-lock mode
(when (fboundp 'global-font-lock-mode)
(global-font-lock-mode t))
;; enable visual feedback on selections
;(setq transient-mark-mode t)
(setq-default line-spacing 5)
;; default to better frame titles
(setq frame-title-format
(concat "%b - emacs@" system-name))
;; default to unified diffs
(setq diff-switches "-u")
(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.
'(display-time-mode t)
'(inhibit-splash-screen t)
'(inhibit-startup-echo-area-message "md")
'(paren-match-face (quote paren-face-match-light))
'(paren-sexp-mode t)
'(pc-selection-mode t nil (pc-select))
'(quote (load-home-init-file t t))
'(show-paren-mode t)
'(transient-mark-mode t))
(set-face-attribute 'mode-line nil :box nil)
;;(custom-set-faces
;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
;; '(default ((t (:stipple nil :background "ivory3" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 90 :width normal :family "adobe-courier")))))
(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.
'(default ((t (:stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 160 :width normal :family "courier"))))
'(compilation-error ((t (:inherit font-lock-warning-face :height 0.5))))
'(font-lock-warning-face ((t (:stipple nil :foreground "Red" :inverse-video nil :underline t :slant normal :weight bold :height 2.0))))
'(secondary-selection ((t (:background "pale green")))))
;; Easier goto-line
(global-set-key "\M-l" 'goto-line)
(global-set-key [(control tab)] 'other-window)
(global-set-key [(control shift down-mouse-1)] 'mouse-drag-secondary)
(put 'narrow-to-region 'disabled nil)
(put 'set-goal-column 'disabled nil)
;;(load-file "~/.emacs.d/cint.el")
;;(load-file "~/.emacs.d/comintx.el")
;;(load-file "~/.emacs.d/cc-ext.el")
;;(load-file "~/.emacs.d/cbrow.el")
;;(global-set-key [f8] 'cint-express)
;;(global-set-key [(shift f8)] 'cint)
;; displays the time in the status bar
(display-time)
(put 'dired-find-alternate-file 'disabled nil)
;;;;
;;; Tags
;; When revisiting the tag file, do not prompt to reload.
(setq tags-revert-without-query t)
(defun rebuild-tags (project-name directory-name tags-file)
"Rebuild tags-file for directory-name."
(eshell-command (format "find %s -type f -name '*.py' | etags -o %s -"
directory-name tags-file))
(message "Rebuilt %s tags file." project-name))
(defun remember-find-tag (tagname)
"Call `find-tag' and remember `last-tag'."
(interactive
(if (bound-and-true-p last-tag)
(list nil)
(list (find-tag-tag "Find tag: "))))
(find-tag tagname t))
;; (defun indent-or-complete ()
;; "Complete if point is at the end of a word, otherwise indent line."
;; (interactive)
;; (if (looking-at "\\>")
;; (dabbrev-expand nil)
;; (indent-for-tab-command)))
(defun indent-or-complete () ;;
"Complete if point is at the end of a word, otherwise indent line." ;;
(interactive) ;;
(if (looking-at "\\>") ;;
(hippie-expand nil) ;;
(indent-for-tab-command)))
(setq hippie-expand-try-functions-list '(try-expand-dabbrev try-expand-dabbrev-all-buffers try-expand-dabbrev-from-kill try-complete-file-name-partially try-complete-file-name try-expand-all-abbrevs try-expand-list try-expand-line try-complete-lisp-symbol-partially try-complete-lisp-symbol)) ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Key more commonly bound to `indent-for-tab-command' command.
(global-set-key (kbd "TAB") 'indent-or-complete)
;; Key more commonly bound to `forward-char' command.
;;(global-set-key (kbd "C-f") 'remember-find-tag)
;; Key more commonly bound to `backward-char' command.
;;(global-set-key (kbd "C-b") 'pop-tag-mark)
; ;; Key more commonly bound to `next-line' command.
;;(global-set-key (kbd "C-n") 'find-tag-other-window)
;; Key more commonly bound to `previous-line' command.
;;(global-set-key (kbd "C-p") 'tags-apropos)
;;(defvar my-project-tags-file
;; "/path/to/my/project/etags_file"
;; "My project tags file.")
;;
;;(defun my-project-build-tags ()
;; "Build my project tags file."
;; (interactive)
;; (rebuild-tags "My Project"
;; "/path/to/my/project"
;; hyperbind-tags-file))
;;
;;;; Visit tags table and rebuild after every save.
;;(visit-tags-table my-project-tags-file)
;;(add-hook 'after-save-hook 'my-project-build-tags)
;; ;;;;;;;;;;;;;;;;;;;;;;; MATLAB ;;;;;;;;;;;;;;;;;;;;;;;;;
;; Put the this file as "matlab.el" somewhere on your load path, then
;; add this to your .emacs or site-init.el file:
;;
;;(load-file "~/.emacs.d/matlab.el")
;; (autoload 'matlab-mode "matlab" "Enter MATLAB mode." t)
;; (setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist))
;; (autoload 'matlab-shell "matlab" "Interactive MATLAB mode." t)
;(autoload 'matlab-mode "matlab" "Matlab Editing Mode" t)
; (add-to-list
; 'auto-mode-alist
; '("\\.m$" . matlab-mode))
; (setq matlab-indent-function t)
; (setq matlab-shell-command "/Appications/MATLAB74/bin/matlab")
;(add-to-list 'load-path
;"/usr/local/matlab7/java/extern/EmacsLink/lisp")
(add-to-list 'load-path
"/Applications/MATLAB74/java/extern/EmacsLink/lisp")
(autoload 'matlab-eei-connect "matlab-eei"
"Connects Emacs to MATLAB's external editor interface.") ;;-- this whole thing needs to be commented out for matlab-shell to work.
(autoload 'matlab-mode "matlab" "Enter Matlab mode." t)
(setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode)
auto-mode-alist))
(autoload 'matlab-shell "matlab" "Interactive Matlab mode." t)
(setq matlab-indent-function t) ; if you want function bodies indented
(setq matlab-verify-on-save-flag nil) ; turn off auto-verify on save
(defun my-matlab-mode-hook ()
(define-key matlab-mode-map [f5] 'matlab-eei-run-continue)
(define-key matlab-mode-map [f9] 'matlab-shell-run-region)
(define-key matlab-mode-map [f10] 'matlab-eei-step)
(define-key matlab-mode-map [f11] 'matlab-eei-step-in)
(eval-after-load "perl-mode"
(define-key matlab-mode-map "\C-c\C-c" 'matlab-comment-region))
(setq fill-column 80)
(imenu-add-to-menubar "Find")) ; where auto-fill should wrap
(add-hook 'matlab-mode-hook 'my-matlab-mode-hook)
(setq matlab-show-mlint-warnings t)
(setq matlab-highlight-cross-function-variables t)
(setq max-specpdl-size 6800)
;; number font face
(defface font-lock-number-face
'((t (:foreground "lime green")))
"Used for numbers and such.")
(defvar my-extra-keywords
'(("\(\<[0-9.]+\>\)" . 'font-lock-number-face)))
;; add it to matlab-mode
(font-lock-add-keywords 'matlab-mode my-extra-keywords)
(setq matlab-shell-command-switches '("-nojvm"))
(setq comint-input-ring-file-name "/Users/mifa/.matlab/R2007a/history.m")
(comint-read-input-ring t)
(defun invert-default ()
(interactive)
(message "I'm here")
(invert-face 'default)
)
;;(invert-default)
(global-set-key "\M-j" 'invert-default)
(global-set-key "\C-c\C-c" 'comment-region) ;Undefined???
;; For the -nw mode
;(global-set-key [C-up] 'backward-paragraph)
;(global-set-key [C-down] "\M-}")
(global-set-key [C-left] "\M-b")
(global-set-key [C-right] "\M-f")
03 May, 2008
Tab completion instead of M-/ (and convenient etags keybindings)
;; When revisiting the tag file, do not prompt to reload.
(setq tags-revert-without-query t)
(defun rebuild-tags (project-name directory-name tags-file)
"Rebuild tags-file for directory-name."
(eshell-command (format "find %s -type f -name '*.py' | etags -o %s -"
directory-name tags-file))
(message "Rebuilt %s tags file." project-name))
(defun remember-find-tag (tagname)
"Call `find-tag' and remember `last-tag'."
(interactive
(if (bound-and-true-p last-tag)
(list nil)
(list (find-tag-tag "Find tag: "))))
(find-tag tagname t))
(defun indent-or-complete ()
"Complete if point is at the end of a word, otherwise indent line."
(interactive)
(if (looking-at "\\>")
(dabbrev-expand nil)
(indent-for-tab-command)))
;; Key more commonly bound to `indent-for-tab-command' command.
(global-set-key (kbd "TAB") 'indent-or-complete)
;; Key more commonly bound to `forward-char' command.
(global-set-key (kbd "C-f") 'remember-find-tag)
;; Key more commonly bound to `backward-char' command.
(global-set-key (kbd "C-b") 'pop-tag-mark)
; ;; Key more commonly bound to `next-line' command.
(global-set-key (kbd "C-n") 'find-tag-other-window)
;; Key more commonly bound to `previous-line' command.
(global-set-key (kbd "C-p") 'tags-apropos)
(defvar my-project-tags-file
"/path/to/my/project/etags_file"
"My project tags file.")
(defun my-project-build-tags ()
"Build my project tags file."
(interactive)
(rebuild-tags "My Project"
"/path/to/my/project"
hyperbind-tags-file))
;; Visit tags table and rebuild after every save.
(visit-tags-table my-project-tags-file)
(add-hook 'after-save-hook 'my-project-build-tags)
30 April, 2008
28 April, 2008
Etags emacs
From http://www.xemacs.org/Documentation/21.5/html/emodules_5.html
Indexing your source code for easy navigation
Emacs comes with an etags executable (and also probably its cousin ctags), which can index source code, allowing you to jump around your source code quickly by simply giving a method name to jump to, etc. Here are some simple steps to get you started:- from a shell, run etags *.[ch] in your source directory, which will index or re-index the .c and .h files in your source directory, and will create a file named TAGS.
- inside emacs, run M-x visit-tags-table RET and then enter the name of the TAGS file created by the previous step.
- for example, to visit a function named "sortRecords", type M-. and then enter the name "sortRecords". Or, better yet, enter just "sortRec", as substrings will work as well, as long as they are unique.
- did your press of M-. not put you in the right function/variable? Then try pressing C-u M-. to visit the next function/variable with a similar name.
- do you want to go back to where you were before the last M-. or C-u M-.? Then simply to M-*, each press of which will pop a stack and return you to where you came from.
03 April, 2008
Alt-Delete in iterm
Ctrl+w
Esc, Ctrl+h or Esc, Delete
Finally, using some unix trickery, I got option+delete working. First, I used the bind command to map Esc, d to backwards delete word. Edit ~/.bash_profile in your favorite text editor and add the line:
bind '"\M-d": backward-kill-word'
(Make sure you have all those quotes, otherwise it doesn't work.)
Now that you have an escape sequence that doesn't require the Ctrl key, you can map option+delete to it in iTerm.
In iTerm, go to Bookmarks > Manage Profiles. Choose Keyboard Profiles > Global and click the + button to add a key binding. Choose delete from the dropdown, check the option checkbox, and then in the Action: dropdown choose escape sequence. In the text field that appears, type d. I also checked the High interception priority checkbox for good measure.
http://hackaddict.blogspot.com/2008/01/delete-backwards-word-with-optiondelete.html
07 February, 2008
10 February, 2007
Dual Boot with Vista
From http://www.cyberciti.biz/tips/howto-fix-dual-boot-windows-vista-linux.html
Step # 1: Boot from Fedora Core Linux 1st CD or DVD
Set BIOS to boot from CD/DVD rom. At boot: prompt type command linux rescueboot: linux rescue
Just follow on screen instructions, when prompted let installer search Linux installation. If the search operation is successful, your old Linux installation will be available at special directory called /mnt/sysimage.
Step # 2: Prepare system for GRUB reinstallation
Type the following commands at shell prompt:# chroot /mnt/sysimage
# cd /boot/grub
chroot command allows to run rest of all *COMMAND* with root directory set to NEWROOT called /mnt/sysimage. Without chroot environment you will not able to restore GRUB on Fedora Core 6.
Step # 3: Find out your GRUB bootloader installation location
If you have only one IDE hard disk default should be /dev/hda. You can use any of the following command to determine your device name:# grep '#boot' grub.confOuput:
#boot=/dev/sda
Above output clearly point out that /dev/sda device where my GRUB bootloader was previously installed.
You can also try out fdisk -l command to list partitions and disk information:# fdisk -l
Step # 4: Reinstall GRUB
Use grub-install command to install GRUB on your drive /dev/sda# grub-install /dev/sda
Please note that if above command returned any error return with –recheck option to probe a device map even if it already exists# grub-install --recheck /dev/sda
Step # 5: Reboot system
Exit from chrooted enviorment and reboot Linux:# sync;sync;exit;exit
# reboot
04 December, 2006
Linux Hacks
For instance,
Get faster file transfer by using 32-bit transfers on your hard drive
Just add the line:
hdparm -c3 /dev/hdX
to a bootup script.
If you use SuSE or other distros based on SYS V,
/sbin/init.d/boot.local
should work for you.
This enables 32-bit transfer on your hard drive. On some systems it can improve transfer performance by 75%.
To test your performance gain, type:
hdparm -t -T /dev/hdX
CPU Scaling
Thanks to Larry Reeder
When I got my 600m, the CPU speed never went above 600 MHz, as shown by cat /proc/cpuinfo, or Gnome's CPU Frequency Scaling applet. I couldn't set the CPU frequency manually, and it wouldn't go up automatically when I was doing a long build. I was beginning to think that the 600m in "Inspiron 600m" stood for 600 MHz.
I was getting a "No speed steps could be determined" error every time I tried to run /etc/init.d/cpuspeed. After trying many things, I noticed that both scaling_max_freq and scaling_min_freq in /sys/devices/system/cpu/cpu0/cpufreq were set to 600000 (600 MHz).
I did: echo 2100000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq and then /etc/init.d/cpuspeed restart
After that the CPU would throttle up to meet demand, and I could also change the speed manually with the Gnome CPU frequency applet.
If you're trying to set various cpuspeed options, I recommend running the commands in /etc/init.d/cpuspeed manually, instead of using the cpuspeed script, which hides many possible error messages when the script has problems. Once you have the options you need, you can go back to using the cpuspeed script.
03 December, 2006
NVidia and FC6
Suspend to RAM
(Courtesy of Firewing1)
1) Make backups of files we're going to edit and install pm-utils:
su -
yum install pm-utils
cp /etc/pm/functions-nvidia /etc/pm/functions-nvidia.backup
cp /boot/grub/grub.conf /etc/grub.conf.backup
Now, edit the /etc/pm/functions-nvidia and commend out this line:
/usr/sbin/vbetool post
in the resume_video() so that the line ends up looking like this:
### /usr/sbin/vbetool post
NOTE: I don't even own a ATi card so I can't test, but if you're seeing similar black screens on a suspend resume, then try editing all the files in /etc/pm and commenting out that line.
2) Next, we have to remove the built-in AGP support and use Nvidia's AGP driver. So, let's edit the /boot/grub/grub.conf, and add agp=off to the kernel line.
See a line like this:
kernel /vmlinuz-2.6.16-1.2096_FC5 ro root=LABEL=/ quiet
agp=off should be added to the end to look like:
kernel /vmlinuz-2.6.16-1.2096_FC5 ro root=LABEL=/ quiet agp=off
Your line may look a little different or the kernel version in the /vmlinuz-... path may not be the same. Please don't change that part, like last time this is just to show where to add the text.
3) Reboot, and you're good to go. Hitting the "suspend" button will put the computer into power-saving mode, and all your previous windows and applications will return to their previous state on resume. I tested with gnome-power-manager:
yum install gnome-power-manager --enablerepo=development
yum update gnome-power-manager --enablerepo=development
That will install / update it to the version I used successfully.
07 October, 2006
OO Browser in XEmacs
Use OOBR(OO-Browser)
OORB shows class structures etc., when you make a program with the language which has classes like C++.
After you execute M-x oobr, you should answer the following questions. The directory under which source (header) files are, the directory under which library header files are, and the path of files such as OOBR, OOBR-FTR. The emacs window is divided after OOBR file is made. Frankly speaking, I am not familiar with OOBR yet. But I think you can use it with the following commands.
- v : Show the definition of class.
- e : Edit class.
- m : Search class with the regular expression.
- c : Show the list of child classes.
- p : Show the list of parent classes.
- t : Show the list of top classes.
narrowing
- Select the function
- Do narrowing.(C-x n n)
- Return to the top.(C-x C-x)
Then, you can see only this function. By typing C-x n w, you reset the state.
using emacs tags
- M-. [symbol-name] : Jump to the definition of the symbol.
- C-x 4 . [symbol-name] : Show the definition of the symbol on another window.
- M-, : Show the next matching.
- M-? [symbol-name] : Show the declaration of the symbol on the mini-buffer.