all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* build-and-save-all
@ 2004-11-29 21:36 Rodrigo Canellas
  0 siblings, 0 replies; 7+ messages in thread
From: Rodrigo Canellas @ 2004-11-29 21:36 UTC (permalink / raw)


Hi,


I would like to create a function that would save all the buffers and then 
build the project being edited.

If I got it tight, in order to run 'make' the cursor must be in the buffer of 
the 'makefile', or at least in a buffer of a file saved in the same directory 
of the 'makefile'. So, before calling 'make', this function must first set 
the 'makefile' buffer as the current buffer.

Does anyone know if something like that already exists? Would someone help me 
on that?


Thanks a lot,

  Rodrigo Canellas

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

* Re: build-and-save-all
       [not found] <mailman.2277.1101765159.27204.help-gnu-emacs@gnu.org>
@ 2004-11-30  5:14 ` Arturs Jurnieks
  2004-12-02 17:58 ` build-and-save-all Kevin Rodgers
  1 sibling, 0 replies; 7+ messages in thread
From: Arturs Jurnieks @ 2004-11-30  5:14 UTC (permalink / raw)


Rodrigo Canellas <r.canellas@terra.com.br> wrote in message news:<mailman.2277.1101765159.27204.help-gnu-emacs@gnu.org>...
> Hi,
> 
> 
> I would like to create a function that would save all the buffers and then 
> build the project being edited.
> 
> If I got it tight, in order to run 'make' the cursor must be in the buffer of 
> the 'makefile', or at least in a buffer of a file saved in the same directory 
> of the 'makefile'. So, before calling 'make', this function must first set 
> the 'makefile' buffer as the current buffer.
> 
> Does anyone know if something like that already exists? Would someone help me 
> on that?
> 
> 
> Thanks a lot,
> 
>   Rodrigo Canellas

What about using the command "Meta-x compile" in your function to invoke makefile?

Just a suggestion...

A.

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

* Re: build-and-save-all
       [not found] <mailman.2277.1101765159.27204.help-gnu-emacs@gnu.org>
  2004-11-30  5:14 ` build-and-save-all Arturs Jurnieks
@ 2004-12-02 17:58 ` Kevin Rodgers
  2004-12-02 20:20   ` build-and-save-all Rodrigo Canellas
       [not found]   ` <mailman.3165.1102019905.27204.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 7+ messages in thread
From: Kevin Rodgers @ 2004-12-02 17:58 UTC (permalink / raw)


Rodrigo Canellas wrote:
> I would like to create a function that would save all the buffers and then 
> build the project being edited.
> 
> If I got it tight, in order to run 'make' the cursor must be in the buffer of 
> the 'makefile', or at least in a buffer of a file saved in the same directory 
> of the 'makefile'. So, before calling 'make', this function must first set 
> the 'makefile' buffer as the current buffer.

Right.  So how do you know where the Makefile is, and what it is called?
Once that's established, it should be simple to implement in Emacs Lisp.

-- 
Kevin Rodgers

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

* Re: build-and-save-all
  2004-12-02 17:58 ` build-and-save-all Kevin Rodgers
@ 2004-12-02 20:20   ` Rodrigo Canellas
       [not found]   ` <mailman.3165.1102019905.27204.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 7+ messages in thread
From: Rodrigo Canellas @ 2004-12-02 20:20 UTC (permalink / raw)


Well, I know that the name of file is 'makefile', so I understand is the name 
of the buffer. I believe there is a function in 'emacs' that returns a list 
of the name of the buffers, and I hope there is another one that returns a 
reference to a buffer given its name, and finally another one that makes a 
buffer the current one, given a reference to it.

As you see, I only have hopes, but I am not sure of none of them. I must add 
that I never wrote a single line of code in Lisp. Yes, I gave myself a big 
trouble. 8)



Em Quinta 02 Dezembro 2004 15:58, Kevin Rodgers escreveu:
> Rodrigo Canellas wrote:
> > I would like to create a function that would save all the buffers and
> > then build the project being edited.
> >
> > If I got it tight, in order to run 'make' the cursor must be in the
> > buffer of the 'makefile', or at least in a buffer of a file saved in the
> > same directory of the 'makefile'. So, before calling 'make', this
> > function must first set the 'makefile' buffer as the current buffer.
>
> Right.  So how do you know where the Makefile is, and what it is called?
> Once that's established, it should be simple to implement in Emacs Lisp.

-- 
Rodrigo Canellas
Engenheiro de Sistemas de Informação

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

* Re: build-and-save-all
       [not found]   ` <mailman.3165.1102019905.27204.help-gnu-emacs@gnu.org>
@ 2004-12-02 22:00     ` Kevin Rodgers
  2004-12-02 22:09       ` build-and-save-all Kevin Rodgers
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Rodgers @ 2004-12-02 22:00 UTC (permalink / raw)


[Please don't top-post.]

Rodrigo Canellas wrote:
 > Well, I know that the name of file is 'makefile', so I understand is
 > the name of the buffer. I believe there is a function in 'emacs' that
 > returns a list of the name of the buffers, and I hope there is another
 > one that returns a reference to a buffer given its name, and finally
 > another one that makes a buffer the current one, given a reference to
 > it.

Actually, buffer-list returns a list of buffers (not their names, nor
"references", which don't exist in Lisp).  And set-buffer is used to
select it.

But none of that is needed, especially since it requires the user to
have already explicitly visited the Makefile, which should not be
necessary.  What I meant was: where in the file system is the project
"makefile", relative to any source file?

For example, here's an implementation that assumes you've created a
"project.dir" symbolic link in each source directory that points to the
project directory:

(defun compile-project ()
   "Compile the project to which this source file belongs."
   (interactive)
   ;; ./project.dir must be a symbolic link to the project directory:
   (let ((default-directory (file-truename "project.dir")))
     (compile "make")))

And here's an implementation that checks the current directory, then its
parent, and so on until it finds a "makefile":

(defun compile-project ()
   "Compile the project to which this source file belongs."
   (interactive)
   ;; The project directory is the closest ancestor directory containing
   ;; a makefile:
   (let* ((default-directory default-directory))
     (while (not (file-exists-p (expand-file-name "makefile"
                                                  default-directory)))
       (when (equal default-directory "/")
         (error "No ancestor \"makefile\" found"))
       (setq default-directory
             (directory-file-name (expand-file-name ".." 
default-directory))))
     (compile "make")))

-- 
Kevin Rodgers

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

* Re: build-and-save-all
  2004-12-02 22:00     ` build-and-save-all Kevin Rodgers
@ 2004-12-02 22:09       ` Kevin Rodgers
  2004-12-03 22:43         ` build-and-save-all Rodrigo Canellas
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Rodgers @ 2004-12-02 22:09 UTC (permalink / raw)


Kevin Rodgers wrote:
 > (defun compile-project ()
 >   "Compile the project to which this source file belongs."
 >   (interactive)
 >   ;; ./project.dir must be a symbolic link to the project directory:
 >   (let ((default-directory (file-truename "project.dir")))
 >     (compile "make")))

I forgot the part about saving all the buffers:

(defun compile-project ()
   "Compile the project to which this source file belongs."
   (interactive)
   ;; ./project.dir must be a symbolic link to the project directory:
   (let ((default-directory (file-truename "project.dir"))
	(compilation-ask-about-save nil))
     (compile "make")))

-- 
Kevin Rodgers

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

* Re: build-and-save-all
  2004-12-02 22:09       ` build-and-save-all Kevin Rodgers
@ 2004-12-03 22:43         ` Rodrigo Canellas
  0 siblings, 0 replies; 7+ messages in thread
From: Rodrigo Canellas @ 2004-12-03 22:43 UTC (permalink / raw)


Thanks! I will try that and let you know.



Em Quinta 02 Dezembro 2004 20:09, Kevin Rodgers escreveu:
> Kevin Rodgers wrote:
>  > (defun compile-project ()
>  >   "Compile the project to which this source file belongs."
>  >   (interactive)
>  >   ;; ./project.dir must be a symbolic link to the project directory:
>  >   (let ((default-directory (file-truename "project.dir")))
>  >     (compile "make")))
>
> I forgot the part about saving all the buffers:
>
> (defun compile-project ()
>    "Compile the project to which this source file belongs."
>    (interactive)
>    ;; ./project.dir must be a symbolic link to the project directory:
>    (let ((default-directory (file-truename "project.dir"))
>  (compilation-ask-about-save nil))
>      (compile "make")))

-- 
Rodrigo Canellas
Engenheiro de Sistemas de Informação

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

end of thread, other threads:[~2004-12-03 22:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.2277.1101765159.27204.help-gnu-emacs@gnu.org>
2004-11-30  5:14 ` build-and-save-all Arturs Jurnieks
2004-12-02 17:58 ` build-and-save-all Kevin Rodgers
2004-12-02 20:20   ` build-and-save-all Rodrigo Canellas
     [not found]   ` <mailman.3165.1102019905.27204.help-gnu-emacs@gnu.org>
2004-12-02 22:00     ` build-and-save-all Kevin Rodgers
2004-12-02 22:09       ` build-and-save-all Kevin Rodgers
2004-12-03 22:43         ` build-and-save-all Rodrigo Canellas
2004-11-29 21:36 build-and-save-all Rodrigo Canellas

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.