[Orgmode] Re: [BABEL] Editing dot blocks with org-exp-blocks
On Wed, Feb 9, 2011 at 11:14 AM, Dan Davison wrote: > Chris Maier writes: >> Is there a way to explicitly associate an major mode with a particular >> kind of language block? > > Hi Chris, > > Yes, see the variable org-src-lang-modes. Use customize, or something > like this: > > #+begin_src emacs-lisp > (aput 'org-src-lang-modes "dot" 'graphviz-dot) > #+end_src > > (Elisp question: I can't remember why we don't use aput in org-mode? > What's the idiomatic org way of doing that? > > This > > #+begin_src emacs-lisp > (setq org-src-lang-modes > (append '(("dot" . graphviz-dot)) > (delq (assoc "dot" org-src-lang-modes) > org-src-lang-modes))) > #+end_src > > doesn't work if there's already more than one entry for "dot") > > Dan org-src-lang-modes I knew I'd seen it somewhere! Thanks for the tip, Dan. Chris ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] [BABEL] Editing dot blocks with org-exp-blocks
The begin_dot is part of org-exp-blocks, as I understand it, and appears required to make it evaluate the Dot code, create the image file, and then incorporate that into the exported document (LaTeX, HTML, etc.) Thanks, Chris On Wed, Feb 9, 2011 at 3:56 AM, Eric S Fraga wrote: > Chris Maier writes: > >> In "normal" Org code blocks (e.g. #+begin_src clojure #+end_src) >> it's possible to hit C-c ' and edit the block code in a separate >> buffer with the appropriate mode. This doesn't appear to work when >> using org-exp-blocks to edit a "begin_dot" block. >> >> Is there a command to do this? > > No idea but what about using #+begin_src dot ... #+end_src? > -- > : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1 > : using Org-mode version 7.4 (release_7.4.324.gca7a) > ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: [BABEL] Editing dot blocks with org-exp-blocks
I fixed my problem... had to dig around in the source of ob-dot.el, though, since it doesn't appear to be on the website [1]. There are some additional undocumented header parameters that ob-dot adds to the standard Babel params. With org-exp-blocks you do this: #+begin_dot foo.png -Tpng ... dot code ... #+end_dot With plain old Babel, you do this: #+begin_src dot :file foo.png :cmdline -Tpng ... dot code ... #+end_src Knowing this now, I'd argue for deprecating org-exp-blocks, too. Now my question changes slightly. With the src block configured as above, I can export and execute the code fine, but when I type C-c ' to edit the Dot code in a separate buffer, it goes into fundamental mode, even though I have graphviz-dot-mode [2] installed and working fine. I suspect it might be because it's called "graphviz-dot-mode" instead of just "dot-mode" (that's just speculation on my part, though). Is there a way to explicitly associate an major mode with a particular kind of language block? Thanks, Chris [1] http://orgmode.org/worg/org-contrib/babel/languages.html [2] http://users.skynet.be/ppareit/projects/graphviz-dot-mode/graphviz-dot-mode.html On Wed, Feb 9, 2011 at 10:14 AM, Dan Davison wrote: > Eric S Fraga writes: > >> Chris Maier writes: >> >>> The begin_dot is part of org-exp-blocks, as I understand it, and >>> appears required to make it evaluate the Dot code, create the image >>> file, and then incorporate that into the exported document (LaTeX, >>> HTML, etc.) >>> >>> Thanks, >>> Chris >>> >>> On Wed, Feb 9, 2011 at 3:56 AM, Eric S Fraga wrote: >>>> Chris Maier writes: >>>> >>>>> In "normal" Org code blocks (e.g. #+begin_src clojure #+end_src) >>>>> it's possible to hit C-c ' and edit the block code in a separate >>>>> buffer with the appropriate mode. This doesn't appear to work when >>>>> using org-exp-blocks to edit a "begin_dot" block. >>>>> >>>>> Is there a command to do this? >>>> >>>> No idea but what about using #+begin_src dot ... #+end_src? >>>> -- >>>> : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1 >>>> : using Org-mode version 7.4 (release_7.4.324.gca7a) >>>> >> >> Yes, I know; I used to use begin_dot and begin_ditaa quite a bit. My >> understanding is that babel knows about dot and therefore provides the >> same functionality, albeit in a different way, > > I vote for removing / deprecating the dot and ditaa functionality of > org-exp-blocks. > > >> possibly more confusing >> but definitely more customisable and hence more powerful. babel gives >> you access to features such as fontification, mode specific editing, >> caching. >> >> I am not sure what the intended long term development for these special >> export blocks might be? org's long term growth (development of >> features) is organic and responsive, not planned per se (and I mean this >> in a positive way as planned software projects seldom achieve their >> goals...) so it may be that nobody can answer this question! >> >> In any case, I didn't mean to imply that you cannot continue using these >> specific export blocks or that they don't do the job they were intended >> for. Simply that maybe babel is the route to go if you want to be able >> to use mode specific editing. > ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] [BABEL] Editing dot blocks with org-exp-blocks
In "normal" Org code blocks (e.g. #+begin_src clojure #+end_src) it's possible to hit C-c ' and edit the block code in a separate buffer with the appropriate mode. This doesn't appear to work when using org-exp-blocks to edit a "begin_dot" block. Is there a command to do this? Thanks, Chris ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] [BABEL] Tangling to a hierarchy of files?
On Wed, Jan 19, 2011 at 10:37 PM, Eric Schulte wrote: > > This has now been added as a new :mkdirp code block header argument, so > it can be set on the block, subtree, file, language, or global level > (see http://orgmode.org/manual/Using-header-arguments.html). > > #+begin_src language :mkdirp yes :tangle nested/directories/target.ext > code body > #+end_src > > Cheers -- Eric > Just got around to incorporating this into my Emacs setup... works like a charm. Thanks for this, Eric! Chris ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] [BABEL] Tangling to a hierarchy of files?
On Wed, Jan 19, 2011 at 12:41 PM, Eric Schulte wrote: > Chris Maier writes: >> >> Is there a place where this and the eval-on-startup trick Charles >> posted are documented? If so, I missed it, and these are both really >> useful to know. >> > > We don't currently have a good place in which to collect such tricks, > probably the closest is a file called scraps.org which I use for > stubbing out examples when responding to mailing list questions or doing > development. Each subheading is a short self-contained example. I do > plan on transforming this at some point into either a page on Worg > "Babel Tricks" or into a "Babel a Day" series or some such. The page is > available at the following (notice this dir. trick is at the top) > https://github.com/eschulte/babel-dev/raw/master/scraps.org Thanks for the link. >>> Would it be possible, to include this into tangling, i.e. if the folder >>> in which the source file should be created does not exist, create it? >>> >>> I remember vaguely a discussion along these lines some time ago, but I >>> don't remember the outcome? >> >> This would be a great feature to have. Eric's embedded Lisp code >> trick will do the job, but I can imagine that it would get cumbersome >> for more complex projects. >> > > This issue has come up recently -- also raised (I believe) by a > Clojurian most likely wanted to create a lein directory layout. > > The reason that I push back against this, is that I often times > accidentally use a tangle path in which the directory does not exist and > the error notification serves as a useful warning that I either > mis-typed the directory or need to create it. > > I would suggest either using the pre-tangle hook, or using my trick > above, which could be made more graceful with the following function > defined... > > #+begin_src emacs-lisp > (defun mkdir-p (file &optional dir) > "Create any parent directories of FILE if missing and return FILE." > (make-directory (file-name-directory file) (or dir ".")) file) > #+end_src > > However given that there seems to be some wide support for this maybe a > customization variable should be introduce, > e.g. org-babel-tangle-mkdirs-p or somesuch... > > Cheers -- Eric A customization variable would be fantastic. Could it be done such that it could be applied (or not applied, according to taste) to a sub-tree of your Org file? That way you could have it disabled on whatever code you might be currently working on so you still see the error messages if you mistype. Then, when you're satisfied with all your tangle paths, you could flip the switch on that sub-tree and have Org do everything for you. Chris ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] [BABEL] Tangling to a hierarchy of files?
On Wed, Jan 19, 2011 at 11:20 AM, Charles C. Berry wrote: > On Wed, 19 Jan 2011, Chris Maier wrote: >> Is there a place where this and the eval-on-startup trick Charles >> posted are documented? If so, I missed it, and these are both really >> useful to know. > > > C-h i, then navigate to > > (emacs)Top > Customization > Variables > File Variables > Specifying File > Variables > > 'eval' is a special kind of file variable. Ah, it's for Emacs in general instead of Org mode... thanks for the tip, Charles. No matter how much you know about Emacs, it seems there's always something new to learn :) Chris ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] [BABEL] Tangling to a hierarchy of files?
On Wed, Jan 19, 2011 at 5:05 AM, Rainer M Krug wrote: > On 01/19/2011 08:22 AM, Eric Schulte wrote: >> >> In addition to the solution Charles posted, it is possible to put >> arbitrary elisp forms into header arguments, so the following >> alternative to your block above will create the directory (if it doesn't >> already exist) whenever the block is tangled or evaluated. >> >> #+begin_src clojure :tangle (prog1 "src/foo.clj" (make-directory "src" ".")) >> (ns foo) >> >> (defn my-inc [x] >> (+ x 1)) >> #+end_src This will do what I'm looking for, thanks! Is there a place where this and the eval-on-startup trick Charles posted are documented? If so, I missed it, and these are both really useful to know. > Would it be possible, to include this into tangling, i.e. if the folder > in which the source file should be created does not exist, create it? > > I remember vaguely a discussion along these lines some time ago, but I > don't remember the outcome? This would be a great feature to have. Eric's embedded Lisp code trick will do the job, but I can imagine that it would get cumbersome for more complex projects. Thanks for all the help, everyone! Chris ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Last workday of the month
Never mind... I think I had something messed up in my initialization file; they're showing up now. Chris On Sat, Oct 30, 2010 at 8:03 PM, Chris Maier wrote: > Where do the functions 'calendar-extract-day', > 'calendar-extract-month', 'calendar-extract-year', and > 'calendar-last-day-of-the-month' come from? I was looking for > something like those when I wrote my initial implementation, but I > don't seem to have them (hence the ugliness of the code!) I'm running > GNU Emacs 23.2 for Mac OS X. Searching for these functions using `C-h > f` turns up nothing for me. > > Thanks for the help, > Chris > > On Sat, Oct 30, 2010 at 4:19 PM, Nick Dokos wrote: >> Chris Maier wrote: >> >>> I'm trying to come up with a sexp diary entry that shows my payday, >>> which is the last weekday of the month, in my Org agenda. I've tried >>> to adapt the example given in the Emacs manual and this is what I came >>> up with: >>> >>> %%(let ((month (car date)) >>> (day (cadr date)) >>> (dayname (calendar-day-of-week date))) >>> (or >>> ;; months with 31 days >>> (and (memq month '(1 3 5 7 8 10 12)) >>> (or (and (= day 31) >>> (memq dayname '(1 2 3 4 5))) >>> (and (memq day '(29 30)) >>> (= dayname 5 >>> ;; months with 30 days >>> (and (memq month '(4 6 9 11)) >>> (or (and (= day 30) >>> (memq dayname '(1 2 3 4 5))) >>> (and (memq day '(28 29)) >>> (= dayname 5 >>> ;; February (the weird one) >>> (and (= month 2) >>> (or (and (memq day '(28 29)) >>> (memq dayname '(1 2 3 4 5))) >>> (and (memq day '(26 27 28)) >>> (= dayname 5)) Chris' Paycheck Deposited >>> >>> It appears to work so far. However, I'm certain there's got to be a >>> more concise way of coding this, but I can't seem to find any >>> pre-existing calendar functions that might help. Am I missing >>> something? >>> >> >> This is based on the same idea and example from the manual, but it >> precalculates what it needs in order to simplify the decision at >> the end: >> >> (let* ((dayname (calendar-day-of-week date)) >> (day (calendar-extract-day date)) >> (month (calendar-extract-month date)) >> (year (calendar-extract-year date)) >> (lastday (calendar-last-day-of-month month year)) >> (last-two-days-before-last-day (list (- lastday 2) (- lastday >> 1 >> (or (and (= day lastday) (memq dayname '(1 2 3 4 5))) >> (and (memq day last-two-days-before-last-day) (= dayname 5))) >> ) >> >> Very lightly tested, so use with caution. >> >>> To make this even better, is there some way to consult another file of >>> diary entries containing all the holidays at my workplace, so the >>> diary entry would show up on the last weekday of the month that is not >>> a company holiday? >>> >> >> I'm sure there is - simplest is probably to set a variable in your >> .emacs with all the holidays - schedule that with org for Dec. 31 :-) - >> but you are on your own for that. I just don't think it's worth it: at >> least for me, there are only three holidays during a year that might >> interfere with that pay schedule. >> >> HTH, >> Nick >> > ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Last workday of the month
Where do the functions 'calendar-extract-day', 'calendar-extract-month', 'calendar-extract-year', and 'calendar-last-day-of-the-month' come from? I was looking for something like those when I wrote my initial implementation, but I don't seem to have them (hence the ugliness of the code!) I'm running GNU Emacs 23.2 for Mac OS X. Searching for these functions using `C-h f` turns up nothing for me. Thanks for the help, Chris On Sat, Oct 30, 2010 at 4:19 PM, Nick Dokos wrote: > Chris Maier wrote: > >> I'm trying to come up with a sexp diary entry that shows my payday, >> which is the last weekday of the month, in my Org agenda. I've tried >> to adapt the example given in the Emacs manual and this is what I came >> up with: >> >> %%(let ((month (car date)) >> (day (cadr date)) >> (dayname (calendar-day-of-week date))) >> (or >> ;; months with 31 days >> (and (memq month '(1 3 5 7 8 10 12)) >> (or (and (= day 31) >> (memq dayname '(1 2 3 4 5))) >> (and (memq day '(29 30)) >> (= dayname 5 >> ;; months with 30 days >> (and (memq month '(4 6 9 11)) >> (or (and (= day 30) >> (memq dayname '(1 2 3 4 5))) >> (and (memq day '(28 29)) >> (= dayname 5 >> ;; February (the weird one) >> (and (= month 2) >> (or (and (memq day '(28 29)) >> (memq dayname '(1 2 3 4 5))) >> (and (memq day '(26 27 28)) >> (= dayname 5)) Chris' Paycheck Deposited >> >> It appears to work so far. However, I'm certain there's got to be a >> more concise way of coding this, but I can't seem to find any >> pre-existing calendar functions that might help. Am I missing >> something? >> > > This is based on the same idea and example from the manual, but it > precalculates what it needs in order to simplify the decision at > the end: > > (let* ((dayname (calendar-day-of-week date)) > (day (calendar-extract-day date)) > (month (calendar-extract-month date)) > (year (calendar-extract-year date)) > (lastday (calendar-last-day-of-month month year)) > (last-two-days-before-last-day (list (- lastday 2) (- lastday > 1 > (or (and (= day lastday) (memq dayname '(1 2 3 4 5))) > (and (memq day last-two-days-before-last-day) (= dayname 5))) > ) > > Very lightly tested, so use with caution. > >> To make this even better, is there some way to consult another file of >> diary entries containing all the holidays at my workplace, so the >> diary entry would show up on the last weekday of the month that is not >> a company holiday? >> > > I'm sure there is - simplest is probably to set a variable in your > .emacs with all the holidays - schedule that with org for Dec. 31 :-) - > but you are on your own for that. I just don't think it's worth it: at > least for me, there are only three holidays during a year that might > interfere with that pay schedule. > > HTH, > Nick > ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Last workday of the month
I'm trying to come up with a sexp diary entry that shows my payday, which is the last weekday of the month, in my Org agenda. I've tried to adapt the example given in the Emacs manual and this is what I came up with: %%(let ((month (car date)) (day (cadr date)) (dayname (calendar-day-of-week date))) (or ;; months with 31 days (and (memq month '(1 3 5 7 8 10 12)) (or (and (= day 31) (memq dayname '(1 2 3 4 5))) (and (memq day '(29 30)) (= dayname 5 ;; months with 30 days (and (memq month '(4 6 9 11)) (or (and (= day 30) (memq dayname '(1 2 3 4 5))) (and (memq day '(28 29)) (= dayname 5 ;; February (the weird one) (and (= month 2) (or (and (memq day '(28 29)) (memq dayname '(1 2 3 4 5))) (and (memq day '(26 27 28)) (= dayname 5)) Chris' Paycheck Deposited It appears to work so far. However, I'm certain there's got to be a more concise way of coding this, but I can't seem to find any pre-existing calendar functions that might help. Am I missing something? To make this even better, is there some way to consult another file of diary entries containing all the holidays at my workplace, so the diary entry would show up on the last weekday of the month that is not a company holiday? Thanks! Chris ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode