emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: src code blocks of type compilation-minor don't work when generating PDF [9.1.14 (9.1.14-dist @ /path/to/org/install/emacs/site-lisp/org/)]
@ 2019-02-01 13:48 John Ciolfi
  2019-02-01 19:04 ` Nick Dokos
  0 siblings, 1 reply; 2+ messages in thread
From: John Ciolfi @ 2019-02-01 13:48 UTC (permalink / raw)
  To: emacs-orgmode


Hi

Using following

  emacs -q --batch -L /path/to/org/install/emacs/site-lisp/org -l my-org-to-pdf.el

the generated PDF is incorrect. The "compilation-minor" code block gets
replaced with the "c" code block, i.e. the c code block is
duplicated. If you generate HTML all is good. Running org-lint doesn't
indicate that one cannot use compilation-minor code blocks.

I'm using Emacs 25.1.1 with the released version of org-mode
9.1.14. It would be nice if this was supported. Alternatively, if
compilation-minor (or compilation) code blocks are not supported could
and error be produced?

Thanks


--- my-org-to-pdf.el ---

(require 'org)
(require 'ox-latex)
(require 'ox-publish)

(defun my-org-to-pdf (org-file)
  "Convert current org-mode buffer to FILE.pdf"
  (find-file org-file)
  (if (not (eq major-mode 'org-mode))
      (error "%S current buffer is not an org file" org-file))
  (let ((org-latex-image-default-width "")
        (org-latex-listings 'minted)
        (org-latex-logfiles-extensions (remove "log" org-latex-logfiles-extensions))
        (org-latex-packages-alist '(("cache=false" "minted")))
        (org-latex-minted-options '(("xleftmargin" "1em")
                                    ("breaklines" "true")
                                    ("fontsize" "\\small")))
        (org-latex-pdf-process
         '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
           "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
        (pdf-file))
    ;; Color the hyper links, see
    ;; https://tex.stackexchange.com/questions/823/remove-ugly-borders-around-clickable-cross-references-and-hyperlinks
    (add-to-list 'org-latex-default-packages-alist
                 '("colorlinks=true,linkcolor={red!50!black},citecolor={blue!50!black},urlcolor={blue!80!black}" "hyperref" nil))
    (setq pdf-file (org-latex-export-to-pdf))
    (set-buffer-modified-p nil)
    (message "Created %S" pdf-file)))

(my-org-to-pdf "foo.org")


--- foo.org ---

#+STARTUP: showall

#+BEGIN_SRC c
double foo(double u) {
    int k;

    int u2 = u + k;

    int u3 = u;

    return(u2 * 2.0);
}
#+END_SRC


#+BEGIN_SRC compilation-minor
foo.c: In function ‘foo’:
foo.c:6:9: warning: unused variable ‘u3’ [-Wunused-variable]
     int u3 = u;
         ^~
foo.c:4:16: warning: ‘k’ is used uninitialized in this function [-Wuninitialized]
     int u2 = u + k;
              ~~^~~
#+END_SRC

<#part type="application/emacs-lisp" filename="/mathworks/devel/sandbox/ciolfi/projects/org_mode/issues/src_block_compilation_minor/my-org-to-pdf.el" disposition=attachment>
<#/part>

<#part type="text/x-org" filename="/mathworks/devel/sandbox/ciolfi/projects/org_mode/issues/src_block_compilation_minor/foo.org" disposition=inline>
<#/part>

<#part type="application/pdf" filename="/mathworks/devel/sandbox/ciolfi/projects/org_mode/issues/src_block_compilation_minor/foo.pdf" disposition=attachment>
<#/part>




Emacs  : GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-09-15, modified by Debian
Package: Org mode version 9.1.14 (9.1.14-dist @ /path/to/org/install/emacs/site-lisp/org/)

current state:
==============
(setq
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe
		      org-babel-header-arg-expand)
 org-speed-command-hook '(org-speed-command-activate
			  org-babel-speed-command-activate)
 org-occur-hook '(org-first-headline-recenter)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-confirm-shell-link-function 'yes-or-no-p
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
		     org-src-mode-configure-edit-buffer)
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-babel-pre-tangle-hook '(save-buffer)
 org-mode-hook '(#[0 "\300\301\302\303\304$\207"
		   [add-hook change-major-mode-hook org-show-block-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)
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn ENTRY)"]
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
		  org-cycle-show-empty-lines
		  org-optimize-window-after-visibility-change)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-link-parameters '(("id" :follow org-id-open)
		       ("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)
		       ("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") ("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-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 )

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

* Re: Bug: src code blocks of type compilation-minor don't work when generating PDF [9.1.14 (9.1.14-dist @ /path/to/org/install/emacs/site-lisp/org/)]
  2019-02-01 13:48 Bug: src code blocks of type compilation-minor don't work when generating PDF [9.1.14 (9.1.14-dist @ /path/to/org/install/emacs/site-lisp/org/)] John Ciolfi
@ 2019-02-01 19:04 ` Nick Dokos
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Dokos @ 2019-02-01 19:04 UTC (permalink / raw)
  To: emacs-orgmode

John Ciolfi <ciolfi@mathworks.com> writes:

> Hi
>
> Using following
>
>   emacs -q --batch -L /path/to/org/install/emacs/site-lisp/org -l my-org-to-pdf.el
>
> the generated PDF is incorrect. The "compilation-minor" code block gets
> replaced with the "c" code block, i.e. the c code block is
> duplicated. If you generate HTML all is good. Running org-lint doesn't
> indicate that one cannot use compilation-minor code blocks.

Hi John,

Given that the produced foo.tex file looks correct, it seems that
since minted does not know what to do with the "compilation-minor"
"language", it goes off a cliff. If you compile it by hand:

   pdflatex --shell-escape foo.tex

it produces an error message:

,----
| (./foo.out.pyg) (./foo.out.pyg) (./foo.toc) (./foo.out.pyg)Error: no
| lexer for alias 'compilation-minor' found system returned with code
| 256 (./foo.out.pyg)
`----

but since it produces a (wrong) PDF, the org exporter does not dig any further.

Changing the language to "c" in the tex file (or in the
source block before re-exporting) produces something a bit better.
Ideally, you'd need to define a lexer for the "compilation-minor" "language",
but that's a minted/pygments project.

Not sure whether it's worth doing anything about this on the org mode side,
but that's not my call.

HTH.

PS. Constantine says "Hi" :-)

-- 
Nick

"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler

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

end of thread, other threads:[~2019-02-01 19:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-01 13:48 Bug: src code blocks of type compilation-minor don't work when generating PDF [9.1.14 (9.1.14-dist @ /path/to/org/install/emacs/site-lisp/org/)] John Ciolfi
2019-02-01 19:04 ` Nick Dokos

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).