From mboxrd@z Thu Jan 1 00:00:00 1970 From: "briangpowell ." Subject: Re: emacs build command for org-files Date: Sun, 26 Jan 2020 16:13:39 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000a6ceac059d1177a5" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:46280) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ivpEA-0005N4-J1 for emacs-orgmode@gnu.org; Sun, 26 Jan 2020 16:13:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ivpE8-0004cE-Il for emacs-orgmode@gnu.org; Sun, 26 Jan 2020 16:13:54 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:34291) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ivpE8-0004b8-8y for emacs-orgmode@gnu.org; Sun, 26 Jan 2020 16:13:52 -0500 Received: by mail-wr1-x42c.google.com with SMTP id t2so8607671wrr.1 for ; Sun, 26 Jan 2020 13:13:52 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Sender: "Emacs-orgmode" To: John Kitchin Cc: org-mode-email --000000000000a6ceac059d1177a5 Content-Type: text/plain; charset="UTF-8" "Actually, if it was possible to get M-x compile to run an elisp function instead of a make file, it might be all I need, but it looks like it runs shell commands." You probably know this but just in case: "You can call simulate an EmacsLisp-based script by putting this in a batch script: emacs -batch -l ~/.emacs.editor --eval="(require 'foo)" \ --eval="(require 'bar)" \ --eval="(some-function $*)" Starting with the Emacs 22, you can write Emacs scripts just as if you were writing Bash or Perl scripts, when you include this at the top of your script file: #!/usr/bin/emacs --script' --I mean, Elisp functions can be called as batch files from shell commands called by make makefiles But I believe you're looking for something better, Python is great, but, it shouldn't be applied to every problem "Python will be the Emacs Lisp of the 1990's"--Guido Van Rossum, in one of his 1st meetings on his new language Python--I was there, I wrote down this quote in an Emacs Lisp book Python is a masterpiece developed at the Stichting Mathematisch Centrum in Amsterdam, Holland--during a Christmas break But Python is, strictly speaking, very similar to Lisp & ELisp There are reasons why functional languages like Lisp, Python, Erlang, Haskell, Clojure, etc. Pure Functional Languages, are still not fully dominating--though Python is very popular For such purposes, time reveals what's best--make makefiles & shell programming will continue to be best for many things Have you looked into emacs-lisp shell--i.e. the "eshell"? --and I believe you can call the "eshell" in batch mode from a shell command--and the "eshell" can execute emacs lisp functions of course --and you can even do all that from the Python interactive shell if you like--and call remote shells from it and/or use "IPython" https://en.wikipedia.org/wiki/IPython On Sun, Jan 26, 2020 at 2:38 PM briangpowell . wrote: > "don't want it to necessarily use Makefiles" > > Why the hey not Dr. Kitchin!? > > Make is an extremely powerful language > > Problem is people make makefiles that are often hard for others to > read--suggest you try hard to keep it simple & avoid the fancy ways of > doing things > > Make has flow control & is a very rich language > > I use makefiles for every project Then Ccc to compile and/or run > everything--in Emacs--can't get easier and faster than that--as long as you > make the makefiles so easy that anyone can read & understand exactly what > it does > > This is my default, which I may edit on-the-fly and just put in another > project name: > > make --ignore-errors --jobs=555 -w --keep-going --warn-undefined-variables > --environment-overrides -f ~/n/n/etc/1cv2tex2doc-project_mak.makefile > 1cv2tex2doc-project-exe > > All slightly interesting ways to improve make have failed slightly, in one > way or another--they catch on for a few years until they're mostly > abandoned--for very good reasons > > Look at it this way: Is there anything wrong with make? Where does it > fail? > > Everyone should learn & use make > > --Brian G. Powell, M.S.--that guy that still loves Makefiles and still > loves using asterisks ("***") as bullets in OrgMode > > On Sun, Jan 26, 2020 at 1:11 PM John Kitchin > wrote: > >> Hi everyone, >> >> This is only semi-on-topic. I am looking for something like M-x compile >> for my org-files, but I don't want it to necessarily use Makefiles. I am >> looking for suggestions of existing solutions to this, or thoughts on how >> to implement this. >> >> Actually, if it was possible to get M-x compile to run an elisp function >> instead of a make file, it might be all I need, but it looks like it runs >> shell commands. >> >> For most of my files, simple exporting is totally adequate. But, some >> files are more complicated, and what I usually do in these cases is write >> an elisp code block in a section that is tagged :noexport: and then I run >> that block to build the result. A recent example was a proposal where I >> needed a pdf of the body, and separate pdf of the references. >> >> I have separate elisp functions that generate these, and then I added >> some custom cleanup code in the block to delete some intermediate >> directories. I don't want to put these in a makefile because they are >> specific to this document. While this works, in a large document I find it >> a little inconvenient to make a small change say at the top, and then to >> jump to the bottom to run the build block to see how it changed. What I >> would prefer is to just run a command like M-x org-compile that would know >> about this build block and run it. That block could of course be a shell >> block that runs a makefile, but it would most often be an elisp block. I >> could even imagine that there is a makefile block that is tangled before >> running a shell block that runs a make command. >> >> What I do in a function now is something like this in a save-excursion: >> >> (when (not (stringp (org-babel-goto-named-src-block "build"))) >> (org-babel-execute-src-block)) >> >> I don't use this in these projects, but they highlight some of the >> complexities I am trying to simplify. These are book like projects with >> special formatting needs, and multiple outputs. >> >> In this project ( >> https://github.com/jkitchin/pycse/blob/master/pycse.org#L15096), I have >> multiple output targets that I would run. >> >> In this project ( >> https://github.com/jkitchin/dft-book/blob/master/dft.org#build) I use >> some temporary filters to save the src blocks to files, and to embed them >> in the pdf so they can be opened. >> >> Anyway, it feels like I am reinventing something here, and that there >> might be some better approach already out there. Maybe some elisp >> equivalent of a makefile or something? >> >> Thoughts? >> >> John >> >> ----------------------------------- >> Professor John Kitchin >> Doherty Hall A207F >> Department of Chemical Engineering >> Carnegie Mellon University >> Pittsburgh, PA 15213 >> 412-268-7803 >> @johnkitchin >> http://kitchingroup.cheme.cmu.edu >> >> --000000000000a6ceac059d1177a5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
"Actually, if it was possible to get M-x compile to r= un an elisp function instead of a make file, it might be all I need, but it= looks like it runs shell commands."

You probab= ly know this but just in case:

"You can call = simulate an EmacsLisp-based script by putting this in a batch script:
emacs -batch -l ~/.emacs.editor --eval=3D"(require 'foo)" \=
--eval=3D"(require 'bar)" \
--eval=3D"(some-funct= ion $*)"
Starting with the Emacs 22, you can write Emacs scripts ju= st as if you were writing Bash or Perl scripts, when you include this at th= e top of your script file:

#!/usr/bin/emacs --script'
<= div>
--I mean, Elisp functions can be called as batch files f= rom shell commands called by make makefiles

But I = believe you're looking for something better, Python is great, but, it s= houldn't be applied to every problem

"Pyt= hon will be the Emacs Lisp of the 1990's"--Guido Van Rossum, in on= e of his 1st meetings on his new language Python--I was there, I wrote down= this quote in an Emacs Lisp book

Python is a mast= erpiece developed at the Stichting Mathematisch Centrum in Amsterdam, Holla= nd--during a Christmas break

But Python is, strict= ly speaking, very similar to Lisp & ELisp

Ther= e are reasons why functional languages like Lisp, Python, Erlang, Haskell, = Clojure, etc. Pure Functional Languages, are still not fully dominating--th= ough Python is very popular

For such purposes, tim= e reveals what's best--make makefiles & shell programming will cont= inue to be best for many things

Have you looked in= to emacs-lisp shell--i.e. the "eshell"?

= --and I believe you can call the "eshell" in batch mode from a sh= ell command--and the "eshell" can execute emacs lisp functions of= course

--and you can even do all that from the Py= thon interactive shell if you like--and call remote shells from it and/or u= se "IPython"=C2=A0https://en.wikipedia.org/wiki/IPython


<= /div>



On Sun, Jan 26, 2020 at 2:38 PM briangpo= well . <briangpowellms@gmail= .com> wrote:
"don't want it to necessarily use Makefiles&q= uot;

Why the hey not Dr. Kitchin!?

Make is an extremely powerful language

Pro= blem is people make makefiles that are often hard for others to read--sugge= st you try hard to keep it simple & avoid the fancy ways of doing thing= s

Make has flow control & is a very rich langu= age

I use makefiles for every project Then Ccc to = compile and/or run everything--in Emacs--can't get easier and faster th= an that--as long as you make the makefiles so easy that anyone can read &am= p; understand exactly what it does

This is my defa= ult, which I may edit on-the-fly and just put in another project name:

make --ignore-errors --jobs=3D555 -w --keep-going --wa= rn-undefined-variables --environment-overrides -f ~/n/n/etc/1cv2tex2doc-pro= ject_mak.makefile 1cv2tex2doc-project-exe

All = slightly interesting ways to improve make have failed slightly, in one way = or another--they catch on for a few years until they're mostly abandone= d--for very good reasons

Look at it this way: Is t= here anything wrong with make?=C2=A0 Where does it fail?

Everyone should learn & use make

--Bria= n G. Powell, M.S.--that guy that still loves Makefiles and still loves usin= g asterisks ("***") as bullets in OrgMode

On Sun, Jan 26, 20= 20 at 1:11 PM John Kitchin <jkitchin@andrew.cmu.edu> wrote:
Hi everyone,
<= br>
This is only semi-on-topic. I am looking for something like M= -x compile for my org-files, but I don't want it to necessarily use Mak= efiles. I am looking for suggestions of existing solutions to this, or thou= ghts on how to implement this.

Actually, if it was= possible to get M-x compile to run an elisp function instead of a make fil= e, it might be all I need, but it looks like it runs shell commands.
<= div>
For most of my files, simple exporting is totally adequa= te. But, some files are more complicated, and what I usually do in these ca= ses is write an elisp code block in a section that is tagged :noexport: and= then I run that block to build the result. A recent example was a proposal= where I needed a pdf of the body, and separate pdf of the references.

I have separate elisp functions that generate these, a= nd then I added some custom cleanup code in the block to delete some interm= ediate directories. I don't want to put these in a makefile because the= y are specific to this document. While this works, in a large document I fi= nd it a little inconvenient to make a small change say at the top, and then= to jump to the bottom to run the build block to see how it changed. What I= would prefer is to just run a command like M-x org-compile that would know= about this build block and run it. That block could of course be a shell b= lock that runs a makefile, but it would most often be an elisp block. I cou= ld even imagine that there is a makefile block that is tangled before runni= ng a shell block that runs a make command.

What I = do in a function now is something like this in a save-excursion:
=
(when (not (stringp (org-babel-goto-named-src-block "bu= ild")))
=C2=A0 =C2=A0 =C2=A0 (org-babel-execute-src-block))

I don't use this in these projects, but they high= light some of the complexities I am trying to simplify. These are book like= projects with special formatting needs, and multiple outputs.
In this project (https://github.com/jkitchin= /pycse/blob/master/pycse.org#L15096), I have multiple output targets th= at I would run.

In this project (https://github.com/jkitchin/dft-book/blob/master/dft.org#build) I use = some temporary filters to save the src blocks to files, and to embed them i= n the pdf so they can be opened.

Anyway, it feels = like I am reinventing something here, and that there might be some better a= pproach already out there. Maybe some elisp equivalent of a makefile or som= ething?=C2=A0

Thoughts?

John

= -----------------------------------
Professor John Kitchin=C2=A0
Dohe= rty Hall A207F
Department of Chemical Engineering
Carnegie Mellon Uni= versity
Pittsburgh, PA 15213
412-268-7803
=
--000000000000a6ceac059d1177a5--