help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving window config using desktop globals


From: Emanuel Berg
Subject: Re: Saving window config using desktop globals
Date: Tue, 15 Dec 2015 05:13:59 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]