Domanda

I have got a question about config of emacs startup behavior. I don't have any idea about lisp, I simply love emacs for editing.

What I would like to have is the following:

  1. I call emacs like emacs FILE
  2. emacs opens a window entitled FILE
  3. emacs splits the window horizontally
  4. in the upper frame it opens a file FILE.abc
  5. goes to the bottom frame and it opens FILE.xyz
  6. optimally comes back to the upper frame

I had a look here: how to create a specific window setup on in .emacs and it's half way through. However, the macro thing doesn't really work in my case because I need to pass an argument. Any help greatly appreciated.

È stato utile?

Soluzione

In general, you will find yourself better served by Emacs if you stay in it just "visit" (as Emacs has been - for 40 years - calling the operation elsewhere known - for 30 years - as "open") files.

Here is the function (untested):

(defun open-two-files (file)
  "Open FILE.abc in the top window and FILE.xyz in the bottom window.
http://stackoverflow.com/questions/15070481/specifying-emacs-startup-behavior"
  (interactive "FEnter file base name: ")
  (let ((old-window (selected-window))
        (new-window (split-window-below)))
    (find-file (concat file ".abc"))
    (select-window new-window)
    (find-file (concat file ".xyz"))
    (select-window old-window)))

You need to put it into your ~/.emacs.el.

Now, if you have emacs already opened, you need to do M-x open-two-files RET foo RET to open foo.abc and foo.xyz.

If you want to start a new Emacs session, type emacs --eval '(open-two-files "foo")'

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top