0

I am trying to avoid using the desktop save mode 1 option in my .emacs file.

We sudo a shared service account, so my buffers may differ from my colleagues buffers.

I launch Emacs from GNU/Linux with emacs -nw (as the sudo'd user) and then I start creating my buffers. We have a monthly machine restart. I do not mind losing my history, but it would be cool if I could save everything and just re-launch that.

If I cannot simply save / relaunch the save, then I'd like to know how to create ~20 buffers by executing a file (if possible).

Also, once I launch a buffer - is it possible to also run commands automatically after the launch?

  • I'm not sure of fully understand what you're asking exactly, but sounds like a custom configuration of recentf-mode to me. – Muihlinn Oct 8 at 17:14
  • Basically after I do: emacs -nw It start a shell and have 4 buffers. then I create 20 buffers. Let's call them buffer a-t C-u M-x shell <RET> a <RET> then do that for b-t I don't want to do that manually and would like the system to do that for me. Once that is done, it would be nice if I could issue a couple of commands per buffer, specific to that buffer. (that is not a requirement) – Scott Baker Oct 8 at 18:20
0

You could automate the opening of those 20 buffers and associate them with shells with something like this called from your init file (code for ilustrative purposes only):

(defun twenty-buffers()
  "Create 20 buffers and associate them to a shell process."
  (interactive)
  (let ((buffer-names (list "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t")))
    (dolist (item buffer-names)
      (shell (get-buffer-create item)))))

You can send input to each shell programmatically just switching to the desired buffer and inserting the text for the command at the end of the buffer this way:

(insert "ls -lah")
(comint-send-input)

On saving the buffers there are various options,but probably I'd go with run-at-time and a function similar to twenty-buffers shown above.

  • I thought I replied to this comment shortly after you posted it. The 'twenty-buffers' works great!. Thanks so much. Now I'd like to add additional tasks after buffer creation: During buffer creation, I'd like: If buffer = 'a', run shell command '. set asdf-a' elseif buffer = 'b', run shell command '.set asdf-b' etc can this be done? – Scott Baker Nov 16 at 3:49
  • you could simply (switch-to-buffer item) after creating the shell then insert the proper command the way shown in the second code block. Shell commands could be a list of strings, one by shell, for example. – Muihlinn Nov 16 at 19:32
0

I would simply set desktop-dirname to something non-conflicting. Then you can safely use desktop as normal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.