Quantcast
Viewing all articles
Browse latest Browse all 20

Code Project Management in Emacs, Part 3

In the Part 1 and Part 2, I talked about getting project management setup using anything and proel to be able to find files within a project and find terms within project files. This time, my topic is a bit more subjective.  The setup described here is probably largely based on my preferences, but since I always like seeing how others interact with their tools, I thought I would post what I do.

This setup was motivated by a lingering lacking feeling I still had when interacting with projects within Emacs.  In Textmate or Aquamacs, it just felt easier to view multiple files at the same time and switch back and forth between them. In Aquamacs, I could do this by just opening a bunch of files and switching amongst the windows (since in Aquamacs I could pin buffers to windows, where I mean window in the operating system sense, not the Emacs sense). My general modus operandi was to have a bunch of files open that I switched between using the normal Emacs buffer switching method ("C-x b"). In Textmate, I would have multiple files open in tabs or in new windows, but again, I would just switch between the windows using Apple-`.

In Carbon Emacs, however, I soon realized that because frames and buffers are decoupled, this method would not really work. After some thinking, I realized that what I really wanted was to have two frames open, each with two windows within them (split horizontally), at all times, and then a way to easily switch amongst those spaces and open the buffer I want in each space. This way, not only would I be able to view multiple files at the same time (I don't think I ever need to view more than 4 at a time), but I could finally do that which I was never really able to do well in Textmate or in Aquamacs - have the spaces taken up by each file be completely distinct and not overlap with each other. I realized that in both Aquamacs and Textmate, I would spend a lot of time moving windows around manually so that they would not overlap with each other so that I could view the files in each window fully at the same time. This manual moving of windows, however, quickly became cumbersome when I had more than 4 or 5 files open. With Carbon Emacs, I have changed the way I think to basically have 4 "spaces" on my screen (where a space is a window within a frame), and in each space, I can have any buffer I want open (which makes it significantly easier to work with lots of buffers).

In addition to what I said above, I wanted to start each frame on a separate monitor in full screen mode (to both try distraction-free coding and also to quell any temptations I might have to use the Finder or Textmate - I am experimenting with existing entirely in Emacs so until I get used to it I don't want to judge if this is actually a better mode of existing). It was definitely non-trivial to get full screen working on a dual-monitor setup, but adding the following to my .emacs worked for me (note that my first monitor is 1400 px wide - you should change the value of left in (setq default-frame-alist '((top . 1) (left . 1450) (width . 80) (height . 53))) so that the second frame opens up in your second monitor):

;; New frames use this size (setq default-frame-alist '((top . 1) (left . 1450) (width . 80) (height . 53))) (setq initial-frame-alist '((top . 1) (left . 1) (width . 80) (height . 53)))   ;; Allow toggling fullscreen (defun fullscreen ()  "toggles whether the currently selected frame consumes the entire display or is decorated with a window border"  (interactive)  (let ((f (selected-frame)))   (modify-frame-parameters f `((fullscreen . ,(if (eq nil (frame-parameter f 'fullscreen)) 'fullboth nil))))))   (split-window-horizontally) (fullscreen) (make-frame-command) (other-frame 1) (split-window-horizontally) (fullscreen)

Note that the above will also let you get out of full-screen mode with "M-x fullscreen".  Setting up the above makes my Emacs look like the screenshot below when I start up:


Finally, I wanted to change up keybindings to make it easier to switch between frames and between windows within the frames. So I added the following to my .emacs:  (global-set-key [C-tab] 'other-frame) (global-set-key "\C-o" 'other-window) (global-set-key "\C-xo" 'mode-line-other-buffer)

This makes control-tab switch between the two frames and C-o switch between the two windows in each frame. Also, C-x o will now switch between the last two buffers I had open.  

Now, the way I tend to work is have the file I am currently working on in my left-most space. Then, when I need to open a different file to compare (or do a grep within my project), I will switch to the second window in my first frame and do it here. In my second frame, I usually have the repl open in the first window, and the last window I leave open for whatever else comes to mind.

I haven't used this setup for that long, and it is taking a bit of getting used to to think of buffers and windows this way, but so far, I think I like this setup better. There are still a few things I wish I could do (and might take the time to set them up) like making a tag search automatically open in a different one of my spaces, or have an option in anything to open a file in a specified space, but for now, I think I am satisfied.

Permalink | Leave a comment  »


Viewing all articles
Browse latest Browse all 20

Trending Articles