all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to set the Makefile directory in emacs
@ 2007-05-11 13:56 Luca Trevisani
  2007-05-11 21:46 ` Peter Dyballa
  2007-05-12  7:48 ` Eli Zaretskii
  0 siblings, 2 replies; 4+ messages in thread
From: Luca Trevisani @ 2007-05-11 13:56 UTC (permalink / raw)
  To: help-gnu-emacs


[-- Attachment #1.1: Type: text/plain, Size: 293 bytes --]

Hi, I am editing a project with source files in many different subfolders. I wonder if I can set in emacs the default folder in wich the Makefile is, so that when I issue the command "make -k" emacs run it in the correct folder no matter where is the file I am editing.

Thank you very much.

[-- Attachment #1.2: Type: text/html, Size: 702 bytes --]

[-- Attachment #2: Type: text/plain, Size: 152 bytes --]

_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

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

* Re: How to set the Makefile directory in emacs
  2007-05-11 13:56 How to set the Makefile directory in emacs Luca Trevisani
@ 2007-05-11 21:46 ` Peter Dyballa
  2007-05-12  7:48 ` Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Dyballa @ 2007-05-11 21:46 UTC (permalink / raw)
  To: Luca Trevisani; +Cc: help-gnu-emacs


Am 11.05.2007 um 15:56 schrieb Luca Trevisani:

> am editing a project with source files in many different  
> subfolders. I wonder if I can set in emacs the default folder in  
> wich the Makefile is, so that when I issue the command "make -k"  
> emacs run it in the correct folder no matter where is the file I am  
> editing.

Launch GNU Emacs from this directory!

Set HOME to that directory!

Add a (dired "/that/elder/directory/with/Makefile/in/it") to your  
~/.emacs!

--
Greetings

   Pete

Bigamy is having one wife too many. Monogamy is the same.     — Oscar  
Wilde

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

* Re: How to set the Makefile directory in emacs
  2007-05-11 13:56 How to set the Makefile directory in emacs Luca Trevisani
  2007-05-11 21:46 ` Peter Dyballa
@ 2007-05-12  7:48 ` Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2007-05-12  7:48 UTC (permalink / raw)
  To: help-gnu-emacs

> From: "Luca Trevisani" <lucatrv@hotmail.com>
> Date: Fri, 11 May 2007 15:56:15 +0200
> 
> Hi, I am editing a project with source files in many different
> subfolders. I wonder if I can set in emacs the default folder in wich
> the Makefile is, so that when I issue the command "make -k" emacs run it
> in the correct folder no matter where is the file I am editing.

Two possible ways:

  . Visit the Makefile and run the "make -k" command from the buffer
    that visits Makefile.

  . Instead of "make -k", use "cd /the/right/folder; make -k" as your
    compilation command.

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

* Re: How to set the Makefile directory in emacs
       [not found] <mailman.525.1178907130.32220.help-gnu-emacs@gnu.org>
@ 2007-06-09 19:36 ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2007-06-09 19:36 UTC (permalink / raw)
  To: help-gnu-emacs

> Hi, I am editing a project with source files in many different
> subfolders. I wonder if I can set in emacs the default folder in wich the
> Makefile is, so that when I issue the command "make -k" emacs run it in
> the correct folder no matter where is the file I am editing.

You can try the following:

(defun compilation-find-file-up (regexp)
  "Look up the directory hierarchy for a file matching REGEXP."
  (catch 'found
    (let ((user (nth 2 (file-attributes default-directory)))
          ;; Abbreviate, so as to stop when we cross ~/.
          (dir (abbreviate-file-name default-directory))
          files)
      (while (and dir (equal user (nth 2 (file-attributes dir))))
        (if (setq files (directory-files dir 'full regexp))
            (throw 'found (car files))
          (if (equal dir
                     (setq dir (file-name-directory
                                (directory-file-name dir))))
              (setq dir nil))))
      nil)))

and then

(setq compile-command
  '(let ((mf (compilation-find-file-up "\\`\\(GNU\\)?[Mm]akefile\\'")))
     (if mf (setq mf (file-name-directory mf)))
     (concat (if (and mf (not (equal mf default-directory)))
                 (format "cd %s; "
                         (shell-quote-argument
                          (file-relative-name
                           (directory-file-name mf)))))
             "make -k ")))


-- Stefan

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

end of thread, other threads:[~2007-06-09 19:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-11 13:56 How to set the Makefile directory in emacs Luca Trevisani
2007-05-11 21:46 ` Peter Dyballa
2007-05-12  7:48 ` Eli Zaretskii
     [not found] <mailman.525.1178907130.32220.help-gnu-emacs@gnu.org>
2007-06-09 19:36 ` Stefan Monnier

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.