all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Saving window config using desktop globals
@ 2015-12-13 19:30 Tim Johnson
  2015-12-13 20:35 ` Tim Johnson
  2015-12-13 22:47 ` Emanuel Berg
  0 siblings, 2 replies; 18+ messages in thread
From: Tim Johnson @ 2015-12-13 19:30 UTC (permalink / raw)
  To: Emacs

Using GNU emacs 24.3 on ubuntu 14.04.

I use the following method
(add-to-list 'desktop-globals-to-save 'current-project-directory)
(add-to-list 'desktop-globals-to-save 'kill-ring)
to save certain variables.

How may I extend this method to save and retrieve my window
configuration? 

at this point, I'm not using more than the default
frame.

I'd like to do this without installing another package. I'm thinking
about using a dedicated register to save one or more configs.

I've tried using C-x r w <ENTER> to save it. But when I restart
emacs and try C-x r j, I get the following:

jump-to-register: Register doesn't contain a buffer position or
configuration

TIA
-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Saving window config using desktop globals
  2015-12-13 19:30 Saving window config using desktop globals Tim Johnson
@ 2015-12-13 20:35 ` Tim Johnson
  2015-12-13 22:47 ` Emanuel Berg
  1 sibling, 0 replies; 18+ messages in thread
From: Tim Johnson @ 2015-12-13 20:35 UTC (permalink / raw)
  To: help-gnu-emacs

* Tim Johnson <tim@akwebsoft.com> [151213 10:33]:
> Using GNU emacs 24.3 on ubuntu 14.04.
> 
> I use the following method
> (add-to-list 'desktop-globals-to-save 'current-project-directory)
> (add-to-list 'desktop-globals-to-save 'kill-ring)
> to save certain variables.
> 
> How may I extend this method to save and retrieve my window
> configuration? 
> 
> at this point, I'm not using more than the default
> frame.
> 
> I'd like to do this without installing another package. I'm thinking
> about using a dedicated register to save one or more configs.
> 
> I've tried using C-x r w <ENTER> to save it. But when I restart
> emacs and try C-x r j, I get the following:
> 
> jump-to-register: Register doesn't contain a buffer position or
> configuration
  Addendum :
  C-x r w p (save window config in register p)
  and then c-h v register-alist
  shows the following:
  ((112 #<window-configuration> #<marker at 2995 in .emacs>)
   (13 "Unprintable entity" #<marker at 5620 in .emacs>)
    (313465889 "Unprintable entity" #<marker in no buffer>))
  Now :
  Save the desktop and close emacs. Re-open emacs
  and retrieve the desktop file.
  then c-h v register-alist
   ((112 "Unprintable entity" #<marker at 2995 in .emacs>)
    (13 "Unprintable entity" #<marker at 5620 in .emacs>)
	 (313465889 "Unprintable entity" #<marker in no buffer>))
  ... No window config

-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Saving window config using desktop globals
  2015-12-13 19:30 Saving window config using desktop globals Tim Johnson
  2015-12-13 20:35 ` Tim Johnson
@ 2015-12-13 22:47 ` Emanuel Berg
  2015-12-13 23:20   ` Emanuel Berg
  2015-12-13 23:27   ` Tim Johnson
  1 sibling, 2 replies; 18+ messages in thread
From: Emanuel Berg @ 2015-12-13 22:47 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson <tim@akwebsoft.com> writes:

> I use the following method (add-to-list
> 'desktop-globals-to-save 'current-project-directory)
> (add-to-list 'desktop-globals-to-save 'kill-ring) to
> save certain variables.
>
> How may I extend this method to save and retrieve my
> window configuration?

It is much easier to understand what you mean and thus
give help if you don't describe the problem in terms
of technology, but rather from a human POV - what is
it, that you want to do, that you cannot? In what
situation will it solve what problem? Etc.

This is one easy way to store and load one window
configuration. I never found much use for it, but it
works, so perhaps it can be useful to you.

If you use it interactively with no prefix argument
(i.e., just M-x <function> RET) then that should
provide basic functionality. More advanced usage than
that, tho possible in principle, I don't see how that
won't get out of hands before anything good can
be riped.

What I recommend are even more simple functions that
will take you to specific buffers, or instances
thereof, for example the one *Article* buffer, and
then shortcuts to those commands (the below will
benefit from shortcuts as well, as always). But it is
your call.

Anyway:

(defvar *default-window-configuration-register* ?0)

(defun save-window-configuration (&optional register)
   (interactive "P")
   (window-configuration-to-register
    (or register *default-window-configuration-register* )))

(defun restore-window-configuration (&optional register)
  (interactive "P")
  (jump-to-register
   (or register *default-window-configuration-register* )))

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Saving window config using desktop globals
  2015-12-13 22:47 ` Emanuel Berg
@ 2015-12-13 23:20   ` Emanuel Berg
  2015-12-13 23:28     ` Emanuel Berg
  2015-12-13 23:27   ` Tim Johnson
  1 sibling, 1 reply; 18+ messages in thread
From: Emanuel Berg @ 2015-12-13 23:20 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> (defvar *default-window-configuration-register* ?0)
>
> (defun save-window-configuration (&optional register)
>    (interactive "P")
>    (window-configuration-to-register
>     (or register *default-window-configuration-register* )))
>
> (defun restore-window-configuration (&optional register)
>   (interactive "P")
>   (jump-to-register
>    (or register *default-window-configuration-register* )))

OK, that doesn't work for interactive use 'cept for
the default call... which is the one I just said one
should stick to, still, if the code is there, it
should work for all uses, for sure.

I suppose this solves that but now you have to pass
registers as lists from Elisp. Perhaps do the
interactive "p" and/or do type checks. I'll leave it
at that at least for tonight...

(defun save-window-configuration (&optional register)
  (interactive "P")
  (window-configuration-to-register
   (or (car register)
       *default-window-configuration-register* )))

(defun restore-window-configuration (&optional register)
  (interactive "P")
  (jump-to-register
   (or (car register)
       *default-window-configuration-register* )))

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Saving window config using desktop globals
  2015-12-13 22:47 ` Emanuel Berg
  2015-12-13 23:20   ` Emanuel Berg
@ 2015-12-13 23:27   ` Tim Johnson
  2015-12-13 23:34     ` Emanuel Berg
  1 sibling, 1 reply; 18+ messages in thread
From: Tim Johnson @ 2015-12-13 23:27 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg <embe8573@student.uu.se> [151213 13:59]:
> Tim Johnson <tim@akwebsoft.com> writes:
> 
> > I use the following method (add-to-list
> > 'desktop-globals-to-save 'current-project-directory)
> > (add-to-list 'desktop-globals-to-save 'kill-ring) to
> > save certain variables.
> >
> > How may I extend this method to save and retrieve my
> > window configuration?
> 
> It is much easier to understand what you mean and thus
> give help if you don't describe the problem in terms
> of technology, but rather from a human POV - what is
> it, that you want to do, that you cannot? In what
> situation will it solve what problem? Etc.
  Thanks for the reply.
  OK: POV -> My pov is the window arrangement.  
    Let's say that my screen is split into 4 windows of equal size. 
	I can save that arrangement in register 'a' by invoking
	c-x r w a.
	As I work, I might find myself with another arrangement and want
	to go back to my original.
	I invoke c-x r j a and bingo! There I have it.

    Can I save the arrangement that I saved in the register 'a
	in my desktop file? My current setup doesn't do that.
	register-alist is not saved to the desktop file with the same
	items that I view from *Help* when I invoke c-h v
	register-alist.

	I appreciate the code you provided. But my main concern is to
	preserve a window layout so that when I close emacs and restart
	or load another desktop and reload the first I desktop can see
	the same layout.

    I hope that this narrative is more clear.
	regards
-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Saving window config using desktop globals
  2015-12-13 23:20   ` Emanuel Berg
@ 2015-12-13 23:28     ` Emanuel Berg
  2015-12-13 23:33       ` Tim Johnson
  0 siblings, 1 reply; 18+ messages in thread
From: Emanuel Berg @ 2015-12-13 23:28 UTC (permalink / raw)
  To: help-gnu-emacs

OK, now it works!

    - M-x no prefix
    - M-x    prefix
    - Elisp plain integer

Man, I like those chained and's and or's... Opens up
a whole new world.

(defvar *default-window-configuration-register* ?0)

(defun save-window-configuration (&optional register)
  (interactive "P")
  (window-configuration-to-register
   (or (and (listp register) (car register))
       register
       *default-window-configuration-register* )))

(defun restore-window-configuration (&optional register)
  (interactive "P")
  (jump-to-register
   (or (and (listp register) (car register))
       register
       *default-window-configuration-register* )))

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Saving window config using desktop globals
  2015-12-13 23:28     ` Emanuel Berg
@ 2015-12-13 23:33       ` Tim Johnson
  2015-12-13 23:41         ` Emanuel Berg
  0 siblings, 1 reply; 18+ messages in thread
From: Tim Johnson @ 2015-12-13 23:33 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg <embe8573@student.uu.se> [151213 14:30]:
> OK, now it works!
> 
>     - M-x no prefix
>     - M-x    prefix
>     - Elisp plain integer
> 
> Man, I like those chained and's and or's... Opens up
> a whole new world.
> 
> (defvar *default-window-configuration-register* ?0)
> 
> (defun save-window-configuration (&optional register)
>   (interactive "P")
>   (window-configuration-to-register
>    (or (and (listp register) (car register))
>        register
>        *default-window-configuration-register* )))
> 
> (defun restore-window-configuration (&optional register)
>   (interactive "P")
>   (jump-to-register
>    (or (and (listp register) (car register))
>        register
>        *default-window-configuration-register* )))
  :) I love your code and your enthusiasm for sharing it, but as you
  might see from my other reply, I really boogered my question and I
  should have said simply:

  "How do I save a register in a desktop file?"
   and if I can't
  "What are options for saving a window layout?"
  So Sorry.
-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Saving window config using desktop globals
  2015-12-13 23:27   ` Tim Johnson
@ 2015-12-13 23:34     ` Emanuel Berg
  0 siblings, 0 replies; 18+ messages in thread
From: Emanuel Berg @ 2015-12-13 23:34 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson <tim@akwebsoft.com> writes:

> Thanks for the reply. OK: POV -> My pov is the
> window arrangement. Let's say that my screen is
> split into 4 windows of equal size. I can save that
> arrangement in register 'a' by invoking c-x r w a.
> As I work, I might find myself with another
> arrangement and want to go back to my original.
> I invoke c-x r j a and bingo! There I have it.
>
> Can I save the arrangement that I saved in the
> register 'a in my desktop file? My current setup
> doesn't do that. register-alist is not saved to the
> desktop file with the same items that I view from
> *Help* when I invoke c-h v register-alist.
>
> I appreciate the code you provided. But my main
> concern is to preserve a window layout so that when
> I close emacs and restart or load another desktop
> and reload the first I desktop can see the
> same layout.
>
> I hope that this narrative is more clear. regards

Aha! Well, what is in a register? Is it data like
any other?

(insert (format "\n;; %s" (get-register 0)))
;; (#<window-configuration> #<marker at 1327 in window-new.el>)

If it is, just write it to a file, next time, load it,
put it in the register, there you go.

If data in registers is special I don't know. If it
is, and there aren't standard methods to get it,
that's bad, but I don't think it is that bad. If there
are methods, use them, it will just be another layer
in between, otherwise the same solution as above.

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Saving window config using desktop globals
  2015-12-13 23:33       ` Tim Johnson
@ 2015-12-13 23:41         ` Emanuel Berg
  2015-12-13 23:48           ` Tim Johnson
  0 siblings, 1 reply; 18+ messages in thread
From: Emanuel Berg @ 2015-12-13 23:41 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson <tim@akwebsoft.com> writes:

> :) I love your code and your enthusiasm for sharing
> it, but as you might see from my other reply,
> I really boogered my question and I should have said
> simply:
>
> "How do I save a register in a desktop file?" and if
> I can't "What are options for saving a window
> layout?" So Sorry.

"Desktop file" = ordinary file?

1. Write data:

(defun write-string-to-file (str file)
  "Write STR to FILE.
FILE is created if it doesn't exist, otherwise it is overwritten."
  (interactive "sstring: \nFfile: ")
  (with-temp-file file (insert str "\n") ))

2. Restore data:

(defun file-to-string (file)
  "Put the contents of FILE into a string and return it."
  (interactive "Ffile: ")
  (with-temp-buffer
    (insert-file-contents file)
    (buffer-string) ))

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Saving window config using desktop globals
  2015-12-13 23:41         ` Emanuel Berg
@ 2015-12-13 23:48           ` Tim Johnson
  2015-12-14  0:20             ` Emanuel Berg
  0 siblings, 1 reply; 18+ messages in thread
From: Tim Johnson @ 2015-12-13 23:48 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg <embe8573@student.uu.se> [151213 14:42]:
> Tim Johnson <tim@akwebsoft.com> writes:
> 
> > :) I love your code and your enthusiasm for sharing
> > it, but as you might see from my other reply,
> > I really boogered my question and I should have said
> > simply:
> >
> > "How do I save a register in a desktop file?" and if
> > I can't "What are options for saving a window
> > layout?" So Sorry.
> 
> "Desktop file" = ordinary file?
   No
   --
   "Desktop file" = .emacs.desktop
-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Saving window config using desktop globals
  2015-12-13 23:48           ` Tim Johnson
@ 2015-12-14  0:20             ` Emanuel Berg
  2015-12-14  0:47               ` Tim Johnson
  0 siblings, 1 reply; 18+ messages in thread
From: Emanuel Berg @ 2015-12-14  0:20 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson <tim@akwebsoft.com> writes:

>> "Desktop file" = ordinary file?
>
>    No -- "Desktop file" = .emacs.desktop

"Desktop will load, at startup, the buffers you were
editing when you last quit Emacs." [1]

Oh no, this is what I said all along...! It is much
better to not care about state but to have a
"total state" where everything is reachable from
everywhere, instantly!

Are people that afraid to get lost?

Good luck anyway.

[1] http://www.emacswiki.org/emacs?action=browse;oldid=DeskTop;id=Desktop

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Saving window config using desktop globals
  2015-12-14  0:20             ` Emanuel Berg
@ 2015-12-14  0:47               ` Tim Johnson
  2015-12-14  0:57                 ` Emanuel Berg
  0 siblings, 1 reply; 18+ messages in thread
From: Tim Johnson @ 2015-12-14  0:47 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg <embe8573@student.uu.se> [151213 15:33]:
> Tim Johnson <tim@akwebsoft.com> writes:
> 
> >> "Desktop file" = ordinary file?
> >
> >    No -- "Desktop file" = .emacs.desktop
> 
> "Desktop will load, at startup, the buffers you were
> editing when you last quit Emacs." [1]
> 
> Oh no, this is what I said all along...! It is much
> better to not care about state but to have a
> "total state" where everything is reachable from
> everywhere, instantly!
> 
> Are people that afraid to get lost?
   :(  
> Good luck anyway.
  I've been using desktop-save-mode for years, but I have not tried
  to save a register. register-alist is being saved in the .desktop
  file, but window configurations are not. 

  I will think about this for a while, and probably repost with a
  better subject line.
  thnx
-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Saving window config using desktop globals
  2015-12-14  0:47               ` Tim Johnson
@ 2015-12-14  0:57                 ` Emanuel Berg
  2015-12-14  1:28                   ` Tim Johnson
  0 siblings, 1 reply; 18+ messages in thread
From: Emanuel Berg @ 2015-12-14  0:57 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson <tim@akwebsoft.com> writes:

> I've been using desktop-save-mode for years, but
> I have not tried to save a register. register-alist
> is being saved in the .desktop file, but window
> configurations are not.

Perhaps you should tell them about it. Even tho
I don't like the idea in principle the idea is in line
with the general idea. So people who like the general
idea should also like such an addition.

> I will think about this for a while, and probably
> repost with a better subject line. thnx

There is always the option of not shutting down your
computer. Then you get a lot of uptime(1) to show off.
The Raspberry Pi is perfectly capable of doing editing
with Emacs. It doesn't make a sound (no fan for the
HD) so you might as well just leave it on. It will
solve the register problem without a single line
of Elisp.

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Saving window config using desktop globals
  2015-12-14  0:57                 ` Emanuel Berg
@ 2015-12-14  1:28                   ` Tim Johnson
  2015-12-15  0:09                     ` [closed]Re: " Tim Johnson
  2015-12-15  4:13                     ` Emanuel Berg
  0 siblings, 2 replies; 18+ messages in thread
From: Tim Johnson @ 2015-12-14  1:28 UTC (permalink / raw)
  To: help-gnu-emacs

* Emanuel Berg <embe8573@student.uu.se> [151213 16:08]:
> Tim Johnson <tim@akwebsoft.com> writes:
> 
> > I've been using desktop-save-mode for years, but
> > I have not tried to save a register. register-alist
> > is being saved in the .desktop file, but window
> > configurations are not.
> 
> Perhaps you should tell them about it. Even tho
> I don't like the idea in principle the idea is in line
> with the general idea. So people who like the general
> idea should also like such an addition.
> 
> > I will think about this for a while, and probably
> > repost with a better subject line. thnx
> 
> There is always the option of not shutting down your
> computer. Then you get a lot of uptime(1) to show off.
> The Raspberry Pi is perfectly capable of doing editing
> with Emacs. It doesn't make a sound (no fan for the
> HD) so you might as well just leave it on. It will
> solve the register problem without a single line
> of Elisp.

   I've written my own system that works with multiple .desktop
   files which handle multiple projects, for me it is not an issue
   of uptime, it's about switching projects...

   Furthermore, a flask project (as one example, could have two
   dozen or more source files).

   BTW: I've settled on emacs as an alternative to vim, which I've
   used for projects for many years. Vim restores window layouts
   quite easily. Vim uses TABS, but I think the usage of registers
   for window layouts (including saving and retrieving them) could
   trump the use of tabs and in the long run make things easier to
   manage.

-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [closed]Re: Saving window config using desktop globals
  2015-12-14  1:28                   ` Tim Johnson
@ 2015-12-15  0:09                     ` Tim Johnson
  2015-12-15  4:40                       ` Stefan Monnier
  2015-12-16  2:27                       ` Emanuel Berg
  2015-12-15  4:13                     ` Emanuel Berg
  1 sibling, 2 replies; 18+ messages in thread
From: Tim Johnson @ 2015-12-15  0:09 UTC (permalink / raw)
  To: Emacs Help

* Tim Johnson <tim@akwebsoft.com> [151213 16:33]:
> 
>    BTW: I've settled on emacs as an alternative to vim, which I've
>    used for projects for many years. Vim restores window layouts
>    quite easily. Vim uses TABS, but I think the usage of registers
>    for window layouts (including saving and retrieving them) could
>    trump the use of tabs and in the long run make things easier to
>    manage.

 As the OP, I'm calling this closed (not solved). I kind of blew the
 subject line. The inquiry evolved to the possibility of saving
 window configs in a register in 'register-alist as stored in a
 .desktop file.

 From further research, it appears to not be possible, as the window
 configs are in C code, not elisp. I'm sure that there are other
 solutions, which I'll pursue later, but it would be great if that
 feature were added.  That way the programmer could
 preserve/serialize several different window layouts for a large
 coding project.

 My thanks to Immanuel for his input.

 I will be temporarily suspending this email address soon, as I will
 be traveling. Should there be any more responses, I can find them
 in the archives.

-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Saving window config using desktop globals
  2015-12-14  1:28                   ` Tim Johnson
  2015-12-15  0:09                     ` [closed]Re: " Tim Johnson
@ 2015-12-15  4:13                     ` Emanuel Berg
  1 sibling, 0 replies; 18+ messages in thread
From: Emanuel Berg @ 2015-12-15  4:13 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson <tim@akwebsoft.com> writes:

> I've written my own system

*nod* :)

> that works with multiple .desktop files which handle
> multiple projects, for me it is not an issue of
> uptime, it's about switching projects...

uptime(1) is a UNIX/GNU tool that tells how long the
system has been up. That is all it does! It is 110
lines of C in the Debian 'procps' package.

The purpose of uptime is unclear save for being able
to boast how long the system has been up - a long
time span would imply a stable system.

There is also a hacker documentary from 2001, "Freedom
Downtime", about Kevin Mitnick. The title refers to
Mitnick being imprisoned - it is a pun on uptime.

If you get a Raspberry Pi and never shut it off, then
you get a lot of uptime if nothing else :)

By the way, I see now on IMDB that "Freedom Downtime"
is directed by "Emmanuel Goldstein" (the Trotsky of
1984). It seems some people have had a lot of fun...

There is also a motion picture on Mitnick which is
much better, "Takedown" ("Operation Takedown" in some
countries) from 2000, but it might not be factual in
every detail...

> Furthermore, a flask project (as one example, could
> have two dozen or more source files).

Are you kidding! (?)

Let's envision the smallest project thinkable, a Unix
shell tool.

- the actual program: one file in C and a header file
- a Makefile
- shell scripts and function files to do automatic testing etc.
- a README file
- a man page, i.e. groff file
- a home page: a HTML and a CSS file
- additional documentation: LaTeX, Biblatex, info, NEWS, gnuplots ...
- archives and metadata files for package managers


So big projects do have a lot of files, and yes, being
able to navigate between them quickly is imperative,
not just to the outcome but also to the enjoyment of
doing it. I always was disheartened when I had to type
long paths in the middle of creative work, which is
why I did tools so to never have to do it.

There are other ways to do what I do, but this is what
I do, and it works for me. But in principle I do
firmly think it is a much better approach than setting
up a window configuration of buffers covering the
entire scope (impossible anyway) and then never
"breaking" it...

Anyway, find files in Emacs:

    http://user.it.uu.se/~embe8573/conf/emacs-init/navigate-fs-keys.el

Ditto the shell:

    http://user.it.uu.se/~embe8573/conf/.zsh/navigate-fs

Find command (currently Emacs and zsh implemented):

    http://user.it.uu.se/~embe8573/conf/emacs-init/ide/find-command.el

This is also useful when config files look like this:

    when-internet-set-time > /dev/null # ~/.zsh/web

(defun find-file-at-line (&optional other-window)
  (interactive "P")
  (let ((possible-filename (thing-at-point 'filename))
        (find-f (if other-window #'find-file-other-window #'find-file)) )
    (if (and possible-filename (file-exists-p possible-filename))
          (apply find-f `(,possible-filename))
      (progn
        (forward-char 1)
        (find-file-at-line) ))))

When we get down to specific situation, this is an
example what you can do:

(defun c-or-cpp-switch-to-body-or-header-file ()
  (interactive)
  (let*((suffixes      (if (eq major-mode 'c-mode) '("c"  "h") '("cc" "hh")))
        (file-suffix   (nth 0 suffixes))
        (header-suffix (nth 1 suffixes))
        (name          (buffer-name)) )
    (let ((is-body                (string= (file-name-extension name) file-suffix))
          (file-name-no-extension (file-name-sans-extension name)) )
      (find-file
       (format "%s/%s" default-directory
               (if is-body
                   (format "include/%s.%s" file-name-no-extension header-suffix)
                 (format "../%s.%s"      file-name-no-extension file-suffix) ))))))

The sky is the limit :)

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [closed]Re: Saving window config using desktop globals
  2015-12-15  0:09                     ` [closed]Re: " Tim Johnson
@ 2015-12-15  4:40                       ` Stefan Monnier
  2015-12-16  2:27                       ` Emanuel Berg
  1 sibling, 0 replies; 18+ messages in thread
From: Stefan Monnier @ 2015-12-15  4:40 UTC (permalink / raw)
  To: help-gnu-emacs

>  From further research, it appears to not be possible, as the window
>  configs are in C code, not elisp. I'm sure that there are other
>  solutions, which I'll pursue later, but it would be great if that
>  feature were added.  That way the programmer could
>  preserve/serialize several different window layouts for a large
>  coding project.

M-x report-emacs-bug is your friend.  This said, I have the impression
that this is already done (at least partly) in newer Emacsen.


        Stefan




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [closed]Re: Saving window config using desktop globals
  2015-12-15  0:09                     ` [closed]Re: " Tim Johnson
  2015-12-15  4:40                       ` Stefan Monnier
@ 2015-12-16  2:27                       ` Emanuel Berg
  1 sibling, 0 replies; 18+ messages in thread
From: Emanuel Berg @ 2015-12-16  2:27 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson <tim@akwebsoft.com> writes:

> From further research, it appears to not be
> possible, as the window configs are in C code,
> not elisp.

Again, if one focuses on the problem, and not on the
particular technology that is perceived to be the
solution, one could do it like this in Elisp:

(defun load-homepage-project ()
  (interactive)
  (delete-other-windows)
  (cd "~/public_html")
  (find-file "style.css")
  (split-window-vertically)
  (find-file "index.html")
  (window-resize nil 5)
  ;; etc.
  
  ;; here, store the window configuration into a register
  ;; as shown in previous code in this thread
)

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2015-12-16  2:27 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-13 19:30 Saving window config using desktop globals Tim Johnson
2015-12-13 20:35 ` Tim Johnson
2015-12-13 22:47 ` Emanuel Berg
2015-12-13 23:20   ` Emanuel Berg
2015-12-13 23:28     ` Emanuel Berg
2015-12-13 23:33       ` Tim Johnson
2015-12-13 23:41         ` Emanuel Berg
2015-12-13 23:48           ` Tim Johnson
2015-12-14  0:20             ` Emanuel Berg
2015-12-14  0:47               ` Tim Johnson
2015-12-14  0:57                 ` Emanuel Berg
2015-12-14  1:28                   ` Tim Johnson
2015-12-15  0:09                     ` [closed]Re: " Tim Johnson
2015-12-15  4:40                       ` Stefan Monnier
2015-12-16  2:27                       ` Emanuel Berg
2015-12-15  4:13                     ` Emanuel Berg
2015-12-13 23:27   ` Tim Johnson
2015-12-13 23:34     ` Emanuel Berg

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.