emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: Org-babel can't capture the output of rg/ag/pt with org-babel on OS X [9.2.6 (9.2.6-4-ge30905-elpaplus @ /Users/maxflander/.emacs.d/elpa/org-plus-contrib-20191014/)]
@ 2019-10-29 21:36 Max Flander
  2020-02-11 13:20 ` Bastien
  2020-02-11 20:15 ` Samuel Wales
  0 siblings, 2 replies; 3+ messages in thread
From: Max Flander @ 2019-10-29 21:36 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

I'm trying to capture the output of rg but I'm getting no output (I'm getting the message "Code block produced no output" in the minibuffer.  

I've also tried ag and pt which don't work either. It works with grep but this is too slow for my use-case.

Example:

#+BEGIN_SRC shell
mkdir -p myproject
pushd myproject
echo "something" > something.txt
rg something
popd
#+END_SRC

#+RESULTS:

I've tried the solutions from these similar questions, but they're not working here:

* https://stackoverflow.com/questions/27304469/capturing-the-output-of-diff-with-org-babel
* https://stackoverflow.com/questions/12771642/capture-output-from-a-shell-command-with-babel-in-org-mode?noredirect=1&lq=1

Emacs  : GNU Emacs 26.3 (build 1, x86_64-apple-darwin18.5.0, NS appkit-1671.40 Version 10.14.4 (Build 18E226))
of 2019-08-30
Package: Org mode version 9.2.6 (9.2.6-4-ge30905-elpaplus @ /Users/maxflander/.emacs.d/elpa/org-plus-contrib-20191014/)

current state:
==============
(setq
org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer)
org-metadown-hook '(org-babel-pop-to-session-maybe)
org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
org-html-format-inlinetask-function 'org-html-format-inlinetask-default-function
org-odt-format-headline-function 'org-odt-format-headline-default-function
org-imenu-depth 8
org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
org-mode-hook '(org-indent-mode #[0 "\301\211\207" [imenu-create-index-function org-imenu-get-tree] 2]
                 #[0 "\300\301\302\303\304$\207" [add-hook change-major-mode-hook org-show-all append local] 5]
                 #[0 "\300\301\302\303\304$\207"
                   [add-hook change-major-mode-hook org-babel-show-result-all append local] 5]
                 org-babel-result-hide-spec org-babel-hide-all-hashes toc-org-enable org-bullets-mode
                 org-eldoc-load)
org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
org-archive-hook '(org-attach-archive-delete-maybe)
org-confirm-elisp-link-function 'yes-or-no-p
org-startup-with-inline-images t
org-agenda-before-write-hook '(org-agenda-add-entry-text)
org-metaup-hook '(org-babel-load-in-session-maybe)
org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn ENTRY)"]
org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
org-babel-pre-tangle-hook '(save-buffer)
org-tab-first-hook '(org-babel-hide-result-toggle-maybe org-babel-header-arg-expand)
org-babel-load-languages '((shell . t))
org-ascii-format-drawer-function #[771 "\207" [] 4 "\n\n(fn NAME CONTENTS WIDTH)"]
org-src-lang-modes '(("arduino" . arduino) ("redis" . redis) ("php" . php) ("C" . c) ("C++" . c++)
                      ("asymptote" . asy) ("bash" . sh) ("beamer" . latex) ("calc" . fundamental) ("cpp" . c++)
                      ("ditaa" . artist) ("dot" . fundamental) ("elisp" . emacs-lisp) ("ocaml" . tuareg)
                      ("screen" . shell-script) ("shell" . sh) ("sqlite" . sql))
org-occur-hook '(org-first-headline-recenter)
org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-show-empty-lines
                  org-optimize-window-after-visibility-change)
org-speed-command-hook '(org-speed-command-activate org-babel-speed-command-activate)
org-odt-format-inlinetask-function 'org-odt-format-inlinetask-default-function
org-confirm-shell-link-function 'yes-or-no-p
org-link-parameters '(("id" :follow org-id-open) ("eww" :follow eww :store org-eww-store-link)
                       ("rmail" :follow org-rmail-open :store org-rmail-store-link)
                       ("mhe" :follow org-mhe-open :store org-mhe-store-link)
                       ("irc" :follow org-irc-visit :store org-irc-store-link :export org-irc-export)
                       ("info" :follow org-info-open :export org-info-export :store org-info-store-link)
                       ("gnus" :follow org-gnus-open :store org-gnus-store-link)
                       ("docview" :follow org-docview-open :export org-docview-export :store org-docview-store-link)
                       ("bibtex" :follow org-bibtex-open :store org-bibtex-store-link)
                       ("bbdb" :follow org-bbdb-open :export org-bbdb-export :complete org-bbdb-complete-link
                        :store org-bbdb-store-link)
                       ("w3m" :store org-w3m-store-link) ("file+sys") ("file+emacs")
                       ("orgit-rev" :store orgit-rev-store :follow orgit-rev-open :export orgit-rev-export
                        :complete orgit-rev-complete-link)
                       ("orgit-log" :store orgit-log-store :follow orgit-log-open :export orgit-log-export
                        :complete orgit-log-complete-link)
                       ("orgit" :store orgit-status-store :follow orgit-status-open :export orgit-status-export
                        :complete orgit-status-complete-link)
                       ("doi" :follow org--open-doi-link) ("elisp" :follow org--open-elisp-link)
                       ("file" :complete org-file-complete-link)
                       ("ftp" :follow (lambda (path) (browse-url (concat "ftp:" path))))
                       ("help" :follow org--open-help-link)
                       ("http" :follow (lambda (path) (browse-url (concat "http:" path))))
                       ("https" :follow (lambda (path) (browse-url (concat "https:" path))))
                       ("mailto" :follow (lambda (path) (browse-url (concat "mailto:" path))))
                       ("news" :follow (lambda (path) (browse-url (concat "news:" path))))
                       ("shell" :follow org--open-shell-link))
org-latex-format-headline-function 'org-latex-format-headline-default-function
org-link-translation-function 'toc-org-unhrefify
org-latex-format-inlinetask-function 'org-latex-format-inlinetask-default-function
org-html-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
org-image-actual-width 400
org-html-format-headline-function 'org-html-format-headline-default-function
)

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

* Re: Bug: Org-babel can't capture the output of rg/ag/pt with org-babel on OS X [9.2.6 (9.2.6-4-ge30905-elpaplus @ /Users/maxflander/.emacs.d/elpa/org-plus-contrib-20191014/)]
  2019-10-29 21:36 Bug: Org-babel can't capture the output of rg/ag/pt with org-babel on OS X [9.2.6 (9.2.6-4-ge30905-elpaplus @ /Users/maxflander/.emacs.d/elpa/org-plus-contrib-20191014/)] Max Flander
@ 2020-02-11 13:20 ` Bastien
  2020-02-11 20:15 ` Samuel Wales
  1 sibling, 0 replies; 3+ messages in thread
From: Bastien @ 2020-02-11 13:20 UTC (permalink / raw)
  To: Max Flander; +Cc: emacs-orgmode@gnu.org

Hi Max,

Max Flander <max.flander@squelch.io> writes:

> I've also tried ag and pt which don't work either. It works with
> grep but this is too slow for my use-case.

Is there any difference between how grep and ag send their output in
the terminal?  If so, can it be relevant to the issue at point?

Thanks,

-- 
 Bastien

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

* Re: Bug: Org-babel can't capture the output of rg/ag/pt with org-babel on OS X [9.2.6 (9.2.6-4-ge30905-elpaplus @ /Users/maxflander/.emacs.d/elpa/org-plus-contrib-20191014/)]
  2019-10-29 21:36 Bug: Org-babel can't capture the output of rg/ag/pt with org-babel on OS X [9.2.6 (9.2.6-4-ge30905-elpaplus @ /Users/maxflander/.emacs.d/elpa/org-plus-contrib-20191014/)] Max Flander
  2020-02-11 13:20 ` Bastien
@ 2020-02-11 20:15 ` Samuel Wales
  1 sibling, 0 replies; 3+ messages in thread
From: Samuel Wales @ 2020-02-11 20:15 UTC (permalink / raw)
  To: Max Flander; +Cc: emacs-orgmode@gnu.org

you probably already tried this to judge from your links but it's
worth poinitng out for mailing list readers that shell blocks use the
exit code.  a user who just wants to run a diff or grep for the stdio
results (stderr and stdout) has to stop that mechanism.

if you want both stdin and stout, you need to combine them.  note that
stderr is normally unbuffered, so the sequence might or might not be
preserved.  and if you want to stop babel from thinking it should do
something different with nonzero ec, you have to stop that.

all of this i think needs to be done in shell code inside the block.


On 10/29/19, Max Flander <max.flander@squelch.io> wrote:
> I'm trying to capture the output of rg but I'm getting no output (I'm
> getting the message "Code block produced no output" in the minibuffer.
>
> I've also tried ag and pt which don't work either. It works with grep but
> this is too slow for my use-case.
>
> Example:
>
> #+BEGIN_SRC shell
> mkdir -p myproject
> pushd myproject
> echo "something" > something.txt
> rg something
> popd
> #+END_SRC
>
> #+RESULTS:
>
> I've tried the solutions from these similar questions, but they're not
> working here:
>
> *
> https://stackoverflow.com/questions/27304469/capturing-the-output-of-diff-with-org-babel
> *
> https://stackoverflow.com/questions/12771642/capture-output-from-a-shell-command-with-babel-in-org-mode?noredirect=1&lq=1
>
> Emacs  : GNU Emacs 26.3 (build 1, x86_64-apple-darwin18.5.0, NS
> appkit-1671.40 Version 10.14.4 (Build 18E226))
> of 2019-08-30
> Package: Org mode version 9.2.6 (9.2.6-4-ge30905-elpaplus @
> /Users/maxflander/.emacs.d/elpa/org-plus-contrib-20191014/)
>
> current state:
> ==============
> (setq
> org-src-mode-hook '(org-src-babel-configure-edit-buffer
> org-src-mode-configure-edit-buffer)
> org-metadown-hook '(org-babel-pop-to-session-maybe)
> org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
> org-html-format-inlinetask-function
> 'org-html-format-inlinetask-default-function
> org-odt-format-headline-function 'org-odt-format-headline-default-function
> org-imenu-depth 8
> org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
> org-mode-hook '(org-indent-mode #[0 "\301\211\207"
> [imenu-create-index-function org-imenu-get-tree] 2]
>                  #[0 "\300\301\302\303\304$\207" [add-hook
> change-major-mode-hook org-show-all append local] 5]
>                  #[0 "\300\301\302\303\304$\207"
>                    [add-hook change-major-mode-hook
> org-babel-show-result-all append local] 5]
>                  org-babel-result-hide-spec org-babel-hide-all-hashes
> toc-org-enable org-bullets-mode
>                  org-eldoc-load)
> org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
> org-archive-hook '(org-attach-archive-delete-maybe)
> org-confirm-elisp-link-function 'yes-or-no-p
> org-startup-with-inline-images t
> org-agenda-before-write-hook '(org-agenda-add-entry-text)
> org-metaup-hook '(org-babel-load-in-session-maybe)
> org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3
> "\n\n(fn ENTRY)"]
> org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
> org-babel-pre-tangle-hook '(save-buffer)
> org-tab-first-hook '(org-babel-hide-result-toggle-maybe
> org-babel-header-arg-expand)
> org-babel-load-languages '((shell . t))
> org-ascii-format-drawer-function #[771 "\207" [] 4 "\n\n(fn NAME CONTENTS
> WIDTH)"]
> org-src-lang-modes '(("arduino" . arduino) ("redis" . redis) ("php" . php)
> ("C" . c) ("C++" . c++)
>                       ("asymptote" . asy) ("bash" . sh) ("beamer" . latex)
> ("calc" . fundamental) ("cpp" . c++)
>                       ("ditaa" . artist) ("dot" . fundamental) ("elisp" .
> emacs-lisp) ("ocaml" . tuareg)
>                       ("screen" . shell-script) ("shell" . sh) ("sqlite" .
> sql))
> org-occur-hook '(org-first-headline-recenter)
> org-cycle-hook '(org-cycle-hide-archived-subtrees
> org-cycle-show-empty-lines
>                   org-optimize-window-after-visibility-change)
> org-speed-command-hook '(org-speed-command-activate
> org-babel-speed-command-activate)
> org-odt-format-inlinetask-function
> 'org-odt-format-inlinetask-default-function
> org-confirm-shell-link-function 'yes-or-no-p
> org-link-parameters '(("id" :follow org-id-open) ("eww" :follow eww :store
> org-eww-store-link)
>                        ("rmail" :follow org-rmail-open :store
> org-rmail-store-link)
>                        ("mhe" :follow org-mhe-open :store
> org-mhe-store-link)
>                        ("irc" :follow org-irc-visit :store
> org-irc-store-link :export org-irc-export)
>                        ("info" :follow org-info-open :export org-info-export
> :store org-info-store-link)
>                        ("gnus" :follow org-gnus-open :store
> org-gnus-store-link)
>                        ("docview" :follow org-docview-open :export
> org-docview-export :store org-docview-store-link)
>                        ("bibtex" :follow org-bibtex-open :store
> org-bibtex-store-link)
>                        ("bbdb" :follow org-bbdb-open :export org-bbdb-export
> :complete org-bbdb-complete-link
>                         :store org-bbdb-store-link)
>                        ("w3m" :store org-w3m-store-link) ("file+sys")
> ("file+emacs")
>                        ("orgit-rev" :store orgit-rev-store :follow
> orgit-rev-open :export orgit-rev-export
>                         :complete orgit-rev-complete-link)
>                        ("orgit-log" :store orgit-log-store :follow
> orgit-log-open :export orgit-log-export
>                         :complete orgit-log-complete-link)
>                        ("orgit" :store orgit-status-store :follow
> orgit-status-open :export orgit-status-export
>                         :complete orgit-status-complete-link)
>                        ("doi" :follow org--open-doi-link) ("elisp" :follow
> org--open-elisp-link)
>                        ("file" :complete org-file-complete-link)
>                        ("ftp" :follow (lambda (path) (browse-url (concat
> "ftp:" path))))
>                        ("help" :follow org--open-help-link)
>                        ("http" :follow (lambda (path) (browse-url (concat
> "http:" path))))
>                        ("https" :follow (lambda (path) (browse-url (concat
> "https:" path))))
>                        ("mailto" :follow (lambda (path) (browse-url (concat
> "mailto:" path))))
>                        ("news" :follow (lambda (path) (browse-url (concat
> "news:" path))))
>                        ("shell" :follow org--open-shell-link))
> org-latex-format-headline-function
> 'org-latex-format-headline-default-function
> org-link-translation-function 'toc-org-unhrefify
> org-latex-format-inlinetask-function
> 'org-latex-format-inlinetask-default-function
> org-html-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
> org-image-actual-width 400
> org-html-format-headline-function
> 'org-html-format-headline-default-function
> )
>
>


-- 
The Kafka Pandemic

What is misopathy?
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html

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

end of thread, other threads:[~2020-02-11 20:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-29 21:36 Bug: Org-babel can't capture the output of rg/ag/pt with org-babel on OS X [9.2.6 (9.2.6-4-ge30905-elpaplus @ /Users/maxflander/.emacs.d/elpa/org-plus-contrib-20191014/)] Max Flander
2020-02-11 13:20 ` Bastien
2020-02-11 20:15 ` Samuel Wales

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).