Re: A probable beginner's mistake

2024-04-21 Thread Mike Gauland

On 22/04/24 06:46, emm.charpent...@free.fr wrote:

Inline "throwaway" code : src_emacs-lisp((+ 2 3)). Does*not*  work.


The inline code should be enclosed in curly brackets: src_emacs-lisp{(+ 
2 3)}


Re: Passing table to Ruby session

2023-08-13 Thread Mike Gauland

On 11/08/23 19:47, Ihor Radchenko wrote:
On Org side, the best we might do is splitting the long command into 
multiline (if ruby REPL supports line continuation like \ this or 
similar). Of course, it will be a workaround.


I've redefined org-babel-ruby-var-to-ruby in my init.el to add a newline 
after each element in an array, which I think will work for anything 
less than a 4k-long string. Ideally, the hard-coded \n would follow the 
EOL convention of the buffer, but I haven't gotten that far yet.



(defun org-babel-ruby-var-to-ruby (var)
  "Convert VAR into a ruby variable.
Convert an elisp value into a string of ruby source code
specifying a variable of the same value."
  (if (listp var)
  (concat "[" (mapconcat #'org-babel-ruby-var-to-ruby var ", \n") "]")
    (if (eq var 'hline)
    org-babel-ruby-hline-to
  (format "%S" var


Re: Passing table to Ruby session

2023-08-10 Thread Mike Gauland

On 10/08/23 21:11, Ihor Radchenko wrote:

Mike Gauland  writes:


Just to follow up on my problem sending a table to ruby. It doesn't'
seem to be an org problem, but with inf-ruby.
...
As long as the code to set the variable is under 4k, it works. When it's
longer than that,  process-send-region sends it in pieces, and inf-ruby
is apparently prematurely interpreting the incomplete code.

I'll take this up elsewhere, though if anyone here has suggestions for
me, or wants further updates, let me know.

4k sounds like a known quirk with pty connection type in Emacs
processes. It may have this 4k limitation at least on some systems.

If you posted a bug report elsewhere, may you please share the link to
that report?

I've reported it to the inf-ruby project: 
https://github.com/nonsequitur/inf-ruby/issues/172


I wasn't aware that Emacs would insert EOF in a stream, but that doesn't 
seem to be the problem (if it is even occurring here).


I've found that both irb and pry will exit if I type ^D at the start of 
a line, but anywhere else it seems to be ignored.






Re: Passing table to Ruby session

2023-08-09 Thread Mike Gauland

On 10/08/23 09:24, Mike Gauland wrote:
Just to follow up on my problem sending a table to ruby. It doesn't' 
seem to be an org problem, but with inf-ruby.


I copied the ruby code that org generates to set the variable, and 
pasted it in to an inf-ruby session, and that works fine.


However, when I select it as a region, and do "ruby-send-region", 
inf-ruby complains about an "unexpected end-of-input".


As long as the code to set the variable is under 4k, it works. When 
it's longer than that,  process-send-region sends it in pieces, and 
inf-ruby is apparently prematurely interpreting the incomplete code.


I'll take this up elsewhere, though if anyone here has suggestions for 
me, or wants further updates, let me know.


Kind regards,

Mike

Just a final note in case any one else has runs into the same problem. I 
got the same results with jruby, but "pry" handles my file without 
complaint.






Re: Passing table to Ruby session

2023-08-09 Thread Mike Gauland
Just to follow up on my problem sending a table to ruby. It doesn't' 
seem to be an org problem, but with inf-ruby.


I copied the ruby code that org generates to set the variable, and 
pasted it in to an inf-ruby session, and that works fine.


However, when I select it as a region, and do "ruby-send-region", 
inf-ruby complains about an "unexpected end-of-input".


As long as the code to set the variable is under 4k, it works. When it's 
longer than that,  process-send-region sends it in pieces, and inf-ruby 
is apparently prematurely interpreting the incomplete code.


I'll take this up elsewhere, though if anyone here has suggestions for 
me, or wants further updates, let me know.


Kind regards,

Mike




Re: Passing table to Ruby session

2023-08-09 Thread Mike Gauland

On 9/08/23 22:14, Ihor Radchenko wrote:

Mike Gauland  writes:


I'll work on putting together a minimal example, if anyone is interested
in testing it on their system.

A minimal example would certainly help.
See https://orgmode.org/manual/Feedback.html#Feedback



Here is an example that demonstrates the problem on my system. I've run 
with my init files disabled, and that makes no difference. Also, I've 
taken the data as it is sent to the session, and pasted into irb in  a 
terminal window, and it ran just fine (which I think rules out any 
problems with line length, or with the session code generating a bad 
script for the longer variable).  I'm keen to find out if anyone else 
can reproduce this, or if there's something quirky about my system.


# Without a session, this works even when the table isn't shortened:
#
#+begin_src ruby :var raw_data=raw-data :colnames no :exports code 
:results output

  puts(raw_data.count)
#+end_src

#+RESULTS:
: 75

# The next two blocks *only* work when the table is cut off at 73. If the
# last two lines are added back in to the table, the ruby session does not
# return.
# Also, even with a truncated table, I don't get any output without the
# extra call to puts() to print a blank line.
#
#+begin_src ruby :var raw_data=raw-data :session :colnames no :exports 
code :results output

  puts(raw_data.count)
  puts()
#+end_src

#+RESULTS:
: 75


#+begin_src ruby :var raw_data=raw-data :session :colnames no :exports 
code :results value

  raw_data.count
#+end_src

#+RESULTS:
: 75


#+NAME: raw-data
| Column 1 | Column 2 | Notes |
|--+--+---|
|    0 |    0 | This is note #0. It just takes up space. |
|    1 |    1 | This is note #1. It just takes up space. |
|    2 |    2 | This is note #2. It just takes up space. |
|    3 |    3 | This is note #3. It just takes up space. |
|    4 |    4 | This is note #4. It just takes up space. |
|    5 |    5 | This is note #5. It just takes up space. |
|    6 |    6 | This is note #6. It just takes up space. |
|    7 |    7 | This is note #7. It just takes up space. |
|    8 |    8 | This is note #8. It just takes up space. |
|    9 |    9 | This is note #9. It just takes up space. |
|   10 |   10 | This is note #10. It just takes up space. |
|   11 |   11 | This is note #11. It just takes up space. |
|   12 |   12 | This is note #12. It just takes up space. |
|   13 |   13 | This is note #13. It just takes up space. |
|   14 |   14 | This is note #14. It just takes up space. |
|   15 |   15 | This is note #15. It just takes up space. |
|   16 |   16 | This is note #16. It just takes up space. |
|   17 |   17 | This is note #17. It just takes up space. |
|   18 |   18 | This is note #18. It just takes up space. |
|   19 |   19 | This is note #19. It just takes up space. |
|   20 |   20 | This is note #20. It just takes up space. |
|   21 |   21 | This is note #21. It just takes up space. |
|   22 |   22 | This is note #22. It just takes up space. |
|   23 |   23 | This is note #23. It just takes up space. |
|   24 |   24 | This is note #24. It just takes up space. |
|   25 |   25 | This is note #25. It just takes up space. |
|   26 |   26 | This is note #26. It just takes up space. |
|   27 |   27 | This is note #27. It just takes up space. |
|   28 |   28 | This is note #28. It just takes up space. |
|   29 |   29 | This is note #29. It just takes up space. |
|   30 |   30 | This is note #30. It just takes up space. |
|   31 |   31 | This is note #31. It just takes up space. |
|   32 |   32 | This is note #32. It just takes up space. |
|   33 |   33 | This is note #33. It just takes up space. |
|   34 |   34 | This is note #34. It just takes up space. |
|   35 |   35 | This is note #35. It just takes up space. |
|   36 |   36 | This is note #36. It just takes up space. |
|   37 |   37 | This is note #37. It just takes up space. |
|   38 |   38 | This is note #38. It just takes up space. |
|   39 |   39 | This is note #39. It just takes up space. |
|   40 |   40 | This is note #40. It just takes up space. |
|   41 |   41 | This is note #41. It just takes up space. |
|   42 |   42 | This is note #42. It just takes up space. |
|   43 |   43 | This is note #43. It just takes up space. |
|   44 |   44 | This is note #44. It just takes up space. |
|   45 |   45 | This is note #45. It just takes up space. |
|   46 |   46 | This is note #46. It just takes up space. |
|   47 |   47 | This is note #47. It just takes up space. |
|   48 |   48 | This is note #48. It just takes up space. |
|   49

Passing table to Ruby session

2023-08-09 Thread Mike Gauland
I'm trying to pass a table to a ruby code block. The table is 211 lines, 
of four columns.


I want to pass it to a session, so I can use the data in subsequent 
blocks.  I've done this successfully on my work laptop, running Windows 
emacs (28.2), with ruby 3.2.


On my linux box (NixOS), however, the code block never completes.  If I 
cut the table down to 65 lines or so, it works just fine.


If I sent the full table to a stand-alone block (no :session), the block 
executes successfully.


Both machines are using ob-ruby.el version 2.4.4 and inf-ruby.el 2.7.0.

If anyone has any thoughts on what might be going on, I'd love to hear 
them. I'm not familiar enough with the code (not yet, anyway) to know 
where to start.


I'll work on putting together a minimal example, if anyone is interested 
in testing it on their system.


Kind regards,

Mike




Re: [BUG] exporting links with underscores

2022-12-16 Thread Mike Gauland

On 17/12/22 11:32, Leo Butler wrote:

Org version is 9.5.2; emacs version is 27.1.

The manual does not indicate that underscores need to be escaped in
links (and they can't be, as far as I can tell). The latex and html
exporters interpret them as the start of a subscript.

Leo

By default underscore is treated that way--see the "Subscripts and 
Superscripts" section of the manual 
(https://orgmode.org/manual/Subscripts-and-Superscripts.html).


Set the '^' option to 'nil' to get the behaviour you're after:

#+OPTIONS: toc:nil num:nil ^:nil

If you want a subscript anywhere, you can get that by using curly braces 
(e.g., ex_{ample}).





Re: Storing database credentials outside an org file

2021-11-01 Thread Mike Gauland

On 1/11/21 4:33 pm, Tim Cross wrote:

Mike Gauland  writes:


I often use an org file to record database queries, using sql source blocks.
I've been putting the database credentials in the file using header-args:sql
properties, but I'd prefer to have the credentials saved in a separate file for
security reasons.

Any ideas on how I could make this work?

It probably wouldn't be too hard to use the authinfo.gpg facility via
the auth-source library which is included in Emacs. In fact, I think
sql-mode might already have support for this built in.

Thanks for the suggestion. I didn't see it on worg, but in ob-sql.el I 
found support for ":dbconnection". I can set up an entry in 
sql-connection-alist, and give the name of the entry to the sql block 
via :dbconnection. Now, my password is safely out of the .org file. As a 
bonus, it is easier to maintain across different org files.







Storing database credentials outside an org file

2021-10-31 Thread Mike Gauland
I often use an org file to record database queries, using sql source 
blocks. I've been putting the database credentials in the file using 
header-args:sql properties, but I'd prefer to have the credentials saved 
in a separate file for security reasons.


Any ideas on how I could make this work?




Re: nbsp as blank

2021-10-19 Thread Mike Gauland

On 20/10/21 12:54 pm, Alexandre Garreau wrote:

Hello,

nbsp (non-breaking space, #xA0) is not recognized as blank in org-mode,
such that “*text* :” (it’s a nbsp here) doesn’t recognize as emphasized…

I recall a variable containing such characters but can’t find it again,
does anyone know? the manual seems large and that looks non-obvious to find
quickly…


I've been using "INVISIBLE SEPARATOR", and invoke:

  (modify-syntax-entry ?⁣ " ")

(there's a invisible separator after the "?"), which tells emacs to 
consider that character to be whitespace.


I know there is a (possibly more than one) variable defining regular 
what can appear immediately before and after emphasis and other markers, 
but I've never puzzled out how to get them to include invisible characters.


I generally use this technique for combining markup, or making a 
marked-up name plural (e.g., ~object name~s).





Re: Using a code block as input to another code block

2020-11-22 Thread Mike Gauland
As far as I know, referencing a code block this way uses the results of 
executing the block as the variable, not the contents of the block.


On 22/11/2020 11:30 am, Magnus Therning wrote:

I know I can use an example block (literal example) as input to a code
block, but I haven't found a way to fontify examples. Since my input is
code (JSON, and various programming languages) I would really like to
have that, as well as the language's mode when editing by using
~org-edit-source-code~.

A code block gives me fontification, but I haven't found a way to pass a
code block as is to another code block.

For instance, something like this:

#+name: code-input
#+begin_src C
#include 
#+end_src

#+begin_src bash :var input=input :results verbatim
cat 

LaTeX Headers not in partial export

2020-10-22 Thread Mike Gauland

Not sure if I'm doing something wrong, or this is expected.

I have a number of #+LATEX directives at the top of my org file, for 
configuring the minted package.


When I export the whole thing to LaTeX, the source blocks are formatted 
with the desired minted options.


If I export only part of the document--either my marking it, or by 
adding an "export" tag--the source blocks are *not* formatted with the 
desired options. On looking at the generated tex file, I find that the 
options from the top of the org file are missing.


Does this sound like a bug, or user (possibly local configuration) 
error? If the former, I'll generate a small file that demonstrates the 
problem.


Kind regards,

MIke





Re: Framing images?

2020-10-01 Thread Mike Gauland

On 1/10/2020 5:59 am, Eric S Fraga wrote:

On Wednesday, 30 Sep 2020 at 11:21, Mike Gauland wrote:

I'd like to have a frame around images in my exported documents. I'm
primarily interested in LaTeX export, but html is a secondary concern.

There are definitely LaTeX ways of doing this (e.g. using mdframed is
the best I've found for general framing of both text and images
[1]).  But obviously these won't work for HTML export.

You might, however, be able to get what you want with a 1 row 1 column
table?

eric

Footnotes:
[1]  https://www.ctan.org/pkg/mdframed
Thanks for the suggestion. In the end, I've found the simplest solution 
for my purposes is to use graphicsmagick to  add a border around the images.




Framing images?

2020-09-29 Thread Mike Gauland
I'd like to have a frame around images in my exported documents. I'm 
primarily interested in LaTeX export, but html is a secondary concern.


Is there any easy way to do this that I'm failing to find?

Kind regards,

Mike





Re: Accessing properties in code blocks

2020-01-09 Thread Mike Gauland

Looking at git, it seems that was introduced in 9.2.

On 10/01/2020 10:32 am, sergio ruiz wrote:

I am getting:

eval: Symbol’s function definition is void: org-macro--get-property

I am using:

Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ 
/Applications/Emacs.app/Contents/Resources/lisp/org/)

Mark set

Is this a newer function?

Thanks!



You can use elisp code to look up the property you want to pass as a 
variable:


#+BEGIN_SRC shell :var url=(org-macro--get-property "url" "")
curl $url
#+END_SRC





peace,
sergio
photographer, journalist, visionary

Public Key: 
https://pgp.key-server.io/pks/lookup?op=get=0x69B08F58923AB3A2

#BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV
@sergio_101@mastodon.social 
https://sergio101.com
http://www.codeandmusic.com
http://www.twitter.com/sergio_101
http://www.facebook.com/sergio101



Re: Accessing properties in code blocks

2020-01-09 Thread Mike Gauland

On 10/01/2020 9:23 am, sergio ruiz wrote:

* Report section
:PROPERTIES:
:url: http://www.googole.com
:END:

I'd like to have several sections like this. Each section woudl have 
different values for the same property. They would make different 
calls to respective url. something like


#+BEGIN_SRC shell
curl 
#+END_SRC

You can use elisp code to look up the property you want to pass as a 
variable:


#+BEGIN_SRC shell :var url=(org-macro--get-property "url" "")
curl $url
#+END_SRC




Re: [org-babel] String interpolation using shell

2020-01-09 Thread Mike Gauland

On 10/01/2020 5:56 am, sergio ruiz wrote:

#+BEGIN_SRC shell :var url_input=url_name
  curl url_input
#+END_SRC

#+RESULTS:

^^ This doesn't work. It is trying to use "url_input" in the curl command.


You need  a $ in front of the name when referencing a variable in the shell:

#+BEGIN_SRC shell :var url_input=url_name
  curl $url_input
#+END_SRC





[O] Getting text at position?

2019-06-09 Thread Mike Gauland
I'd like to be able to be able to get the text associated with a given 
heading (based on the current point, for example).


Can anyone point me to an example for doing this in the approved manner 
(assuming there is one), or to functions to help with this?


Kind regards,
Mike




Re: [O] Org-mode as a metalanguage: calling SQL functions

2013-04-01 Thread Mike Gauland
Gary Oberbrunner garyo at oberbrunner.com writes:
 Is this supposed to work?
 -- Gary

I'm not sure how it's /supposed/ to work, either, but this example works for a
sqlite database I've been playing with:

  #+NAME: artist
  #+BEGIN_SRC sqlite :db the_sound_A-Z.sql :var song_title=
  select artist from playlist where title==$song_title;
  #+END_SRC

  #+CALL: artist(song_title=Pressure)

  #+RESULTS: artist(song_title=Pressure)
  : Billy Joel

Note the need for double quotes around $song_title in the SRC block.

I'm using the latest from git, and emacs 23.2.1 on Debian.

Hope that helps.

Kind Regards,
Mike Gauland






[O] :wrap behaviour

2013-02-28 Thread Mike Gauland
I've been using the :wrap parameter extensively, to give me control over the
formatting of results from code blocks.  For files with many such blocks, it
makes sense to specify the formatting at the file level. This works well, unless
I want a particular block to be unwrapped. Just specifying :wrap with no
parameter wraps the output in #+BEGIN_RESULTS...#+END_RESULTS, which is *not*
what I want. The only way to get what I want is to move :wrap from the file
level to each block I *do* want wrapped.

I'd like to be able to disable wrapping for particular blocks. I've started
experimenting with code to do that, but I'm not sure what the best behaviour
should be, and would appreciate suggestions.

Some ideas I've considered:
  + Have :wrap by itself disable wrapping; if you want to wrap in   
BEGIN_RESULTS..END_RESULTS you'll have to specify :wrap RESULTS.
  + Use a special string (e.g., :wrap off) to disable wrapping. Of course,
this makes it impossible to wrap your output in a BEGIN_OFF..END_OFF block, 
 
should you ever want to do that.
  + Use a special symbol instead of a string to turn off wrapping (e.g., :wrap 
:off)

Kind Regards,
Mike Gauland




Re: [O] How to make the new exporter open PDF using evince?

2013-02-24 Thread Mike Gauland
James Harkins jamshark70 at gmail.com writes:

 
 A quick web search didn't turn up anything handy, so I thought I'd ask here.
 
 Is it possible to configure the new exporter to open a PDF (generated
 by LaTeX) using evince instead of okular?

I think you can do that my changing the order of the entries in /etc/mailcap,
but it's been a while since I've mucked with that.




[O] Previewing inline-LaTeX with imagemagick?

2012-07-02 Thread Mike Gauland
I've been playing with tikz to create a flowchart in my org file. The image is
rendered correctly when I export to PDF, of course, and setting the 'latex'
option to 'imagemagick' generates a PNG when I export the file to HTML. However,
if I try to preview that block with org-preview-latex-fragment (C-c C-x C-l), I
 just get a blank square (a placeholder).

I think this is because dvipng doesn't handle the postscript generated by tikz.
I've worked around this by shadowing the system dvipng with a script in my local
bin directory, that sends the dvi through dvips then convert to generate the
png. This also works for HTML export (using latex:dvipng).  

The new 'latex:imagemagick' option is a cleaner solution. Would it be possible
to use the same code for previewing fragments?

I'm happy to help with the necessary changes, if some knowledgeable with the
relevant source code can get me started in the right direction.

--Mike





[Orgmode] Re: [babel] support plantuml

2010-08-25 Thread Mike Gauland
This looks very useful, but I'm having trouble getting it to work. Do you have
an example?

I tried this:
#+BEGIN_SRC plantuml :file uml.png
Alice - Bob: Authentication Request
Bob -- Alice: Authentication Response

Alice - Bob: Another authentication Request
Alice -- Bob: another authentication Response
#+END_SRC

If I also change 'at enduml' to '@uml' in this line:
 (with-temp-file in-file (insert (concat @startuml\n body \n at 
enduml)))

I can get an image if I evaluate the block manually (e.g., via 'C-c C-c' with
the cursor on the BEGIN block), but when I export the file the image is invalid.

Any suggestions would be appreciated.

Thanks,
Mike





___
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] support plantuml

2010-08-25 Thread Mike Gauland
Mike Gauland mikelygee at gmail.com writes:

 I can get an image if I evaluate the block manually (e.g., via 'C-c C-c' with
 the cursor on the BEGIN block), but when I export the file the image is
 invalid.

I figured it out.  I was getting extra carriage returns in the file. I've fixed
them by setting coding-system-for-write to 'no-conversion within the (let).

--Mike




___
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] Indentation in html tables

2010-07-16 Thread Mike Gauland
 I frequently use a columnview dynamic block to create a table (generally a task
list, with effort estimates and notes). I export these to HTML, so they look
pretty for my Emacsphobic colleagues.  I've noticed that when my table includes
nested levels, sometimes the level is indicated in the HTML with *'s, and other
times a span of invisible x's is used instead.  I haven't had any luck trying
to figure out why this happens, or what I'm doing differently to get one or the
other. Can anyone explain this?

I prefer to use padding for indentation, since some of my headings get wrapped
to several lines. Padding prevents the second and subsequent lines from starting
at the left edge, making the structure of the table clearer.  For those who
share this preference, I present the following from my .emacs. When exporting a
table to HTML, it replaces invisible x's with *'s, and converts *'s to a padding
directive:

(add-hook 'org-export-html-final-hook
  (lambda ()
(goto-char (point-min))
(while (re-search-forward td\\(\\*+\\)  nil t)
  (replace-match 
   (format td style=\padding-left:%dem\
   (- (length (match-string 1)) 1)))
  )))
(add-hook 'org-export-html-final-hook
  (lambda () 
(goto-char (point-min))
(while (re-search-forward span
style=\visibility:hidden;\\\(\\x+\\)/span nil t)
  (replace-match (concat (make-string (length (match-string 1)) ?*)
 ))
  )))



___
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] Estimate ranges in column view

2010-06-17 Thread Mike Gauland
When planning my work, I estimate the effort required as a range, rather than a
single value. That is, instead of estimating a certain task will take 4 days,
I'll use a range of 3-5 days. If I'm a bit less confident I know how long it
will take, I'll use a wider range (e.g., 2-6 days).  

When I first started doing this, I switched from using a single 'Effort' column
in org mode, to two columns (Effort_Low and Effort_High), simply summing each
column to get an estimate for a composite task.  However, this magnifies the
level of uncertainty in the estimate. The final 'Effort_Low' value tells me what
to expect if everything goes optimally; 'Effort_High' provides the extremely
pessimistic view.

More realistic summaries come from considering the range of each pair, using the
combined statistical variance in each (low, high) pair to determine the variance
in the final value. This is the method used by LiquidPlanner, for example.

I've been mucking about with org-colview.el to automate this calculation for me,
and am quite pleased with the results so far. I've approached this by adding a
new summary type (est) to org-columns-compile-map, and extending
org-columns-number-to-string and org-columns-string-to-number to convert ranges
to and from strings. This lets me populate an 'Estimates' column with values
such as [2 4], and specify a summary type est to have the algorithm
described above used to produce the final estimates.

I have two questions for the list:

  1. Is this the right approach, or should I change the behaviour of the
existing EFFORT property?
  2. Is this something others would find useful?

Thanks,
Mike



___
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