Thursday, March 29, 2012

emacs: Cycle windows backward

To cycle windows in emacs you can use the shortcut c-x o that executes the command other-window. Now to cycle windows in the reverse order you need to execute the command other-window with argument -1 (other-window accepts integer as argument, being the number of windows to jump). So I added this code to my .ecmas file:
;; cycle windows in reverse order
(defun prev-window ()
  (interactive)
  (other-window -1)
)
(global-set-key (kbd "C-x p") 'prev-window)
This will create the command prev-window and assign the shortcut C-x p to this function. Note: C-x p is by default assigned to narrow-to-page, a function I never used... This Idea I found it originally in Quora.com

Resize windows in emacs

To easily resize windows in emacs I added the following key shortcuts:
;; * \author Pedro Parracho   
;; Resizing windows using alt-arrow
 (global-set-key (kbd "\033[1;9D") 'shrink-window-horizontally) ;;alt-left: code ^[[1;9D                                                    
 (global-set-key (kbd "\033[1;9C") 'enlarge-window-horizontally) ;; alt-right: code ^[[1;9C                                                 
 (global-set-key (kbd "\033[1;9A") 'shrink-window) ;; alt-up: code ^[[1;9A                                                                  
 (global-set-key (kbd "\033[1;9B") 'enlarge-window) ;; alt-down: code ^[[1;9B                                                               
Now alt-arrow will change the window size by a step.

Monday, March 26, 2012

GNU screen renumber windows

When working a long time with a screen session, you might get holes in the screen numbering, to change the number of the current windows do ctrl-a : number <number>
There is a script that will renumber all the windows in a session, you can find it in http://brainscraps.wikia.com/wiki/Renumbering_GNU_Screen_Windows

Swap two characters in emacs

To transpose 2 characters the emacs command is transpose-chars and the shortcut is C-t.
For words the command is transpose-words and the shortcut is M-t.

Thursday, March 22, 2012

Go to next unread message in Mail via keyboard

A long standing annoyance in Mail is that there is no keyboard shortcut to skip to the next message. I found in hints.macworld.com a apple script that will jump to the next unread mail on ctr-n.
I changed the script to jump to the last item and not the first, as I like to read my messages by chronological order.
try
 tell application "Mail"
  activate
  tell the front message viewer
   set unreadMessages to (the messages whose ¬
    read status is false) as list
   if (count of unreadMessages) is not 0 then
    set selected messages to {the last item of unreadMessages}
   else
    beep
   end if
  end tell
 end tell
on error error_message
 beep
 display dialog "Error looking for next unread message: " & ¬
  return & return & error_message buttons {"OK"} default button 1
end try
To have this script activated, instead of copying it to the mail script folder as suggested in the article, I created a new service with "no input" in "Mail.app" that will run the apple script on the top. Saved the service, and added the shortcut ctrl-n in the keyboard settings.

Wednesday, March 21, 2012

SvnX hurdles

I was having 1 problem common to svn and svnx. The problem was the message: "Killed by signal 15."

I found out that this was something that happens for svn > 1.6.6.

The solution according to old.nabble.com is to add the option -p to the ssh command in your svn configuration file ~/.subversion/config

The other problems was /usr/bin/xauth: error in locking authority file .Xauthority this got solved by adding the option -x

My line in ~/.subversion/config is now:
ssh = $SVN_SSH ssh -o ControlMaster=no -q -x

Tuesday, March 06, 2012

regexp and emacs

You can test your regular expression in emacs by activating the mode regexp-builder.

 Note: the regexp-builder by default will use the lisp syntax, to use the one that emacs use in replace-regexp command you need to change the syntax mode using the command reb-change-syntax, use the value string.

 Another nice way to test your regexp is in this website http://gskinner.com/RegExr/

Monday, March 05, 2012

Great clipboard manager

FlyCut seems to be a very nice clipboard manager, based in the Jumpcut. You can find it in the App store, or bettr yet in the git: https://github.com/TermiT/flycut