ox-hugo github actions : Debugger entered--Lisp error: (void-function org-hugo-export-wim-to-md) Error: Process completed with exit code 255 - emacs

Im trying to deploy my hugo site on github actions. Im using the following github action which does the following :
1.On Ubuntu
2.Setup up emacs
3.git clone ox-hugo package
4.ox-hugo package should convert my .org files to .md
setup and build using Hugo and deploy
https://gist.github.com/shwetarkadam/d890b7054b65fe21b63609ca03650bdc
I'm facing an issue on step 4 where I encounter the following error on GitHub action :
Run emacs ./config.org --batch -L ./ox-hugo -L ox-hugo.el --eval="(org-hugo-export-wim-to-md t)" --kill
Debugger entered--Lisp error: (void-function org-hugo-export-wim-to-md)
(org-hugo-export-wim-to-md t)
eval((org-hugo-export-wim-to-md t) t)
command-line-1(("./config.org" "-L" "./ox-hugo" "-L" "ox-hugo.el" "--eval=(org-hugo-export-wim-to-md t)" "--kill"))
command-line()
normal-top-level()
Approaches tried till now :
Changing (org-hugo-export-wim-to-md t) to (org-hugo-export-wim-to-md :all-subtrees)
Adding the expression (org-hugo-export-wim-to-md :all-subtrees) in single quotes and double quotes.

I happened to be working on a similar problem today. I had searched for guidance on it and I stumbled across Batch export of org-mode files from the command line which led me to fniessen/orgmk and in orgmk.el in particular.
After experimenting in my *scratch* buffer and asking Emacs' various help facilities a few questions, I bludgeoned my way to a standalone file containing Emacs Lisp code that appears to work independently of my initialization files.
$ touch export.el
$ emacs -q --batch -l export.el
Designating package sites
Designating package site melpa-stable => https://stable.melpa.org/packages/
Designating package site melpa => https://melpa.org/packages/
Designating package site gnu => https://elpa.gnu.org/packages/
Installing package ox-hugo
Setting ‘package-selected-packages’ temporarily since "emacs -q" would overwrite customizations
‘ox-hugo’ is already installed
Exporting org subtrees to hugo from content.org
1 files scanned, 0 files contains IDs, and 0 IDs found.
[ox-hugo] 1/ Exporting ‘Redacted site title’ ..
[ox-hugo] 2/ Exporting ‘Posts’ ..
[ox-hugo] 3/ Exporting ‘Redacted post title’ ..
[ox-hugo] Exported 3 subtrees from content.org in 0.510s (0.170s avg)
Exporting all org subtrees in all files in /redacted/directory
$ find content -newer export.el
content
content/_index.md
content/posts
content/posts/redacted-post-title.md
content/posts/_index.md
(Some names have been changed to protect the guilty er um I mean innocent.)
The file export.el contains:
(defvar my/package-archives
(list
(cons "melpa-stable" "https://stable.melpa.org/packages/")
(cons "melpa" "https://melpa.org/packages/")
(cons "gnu" "https://elpa.gnu.org/packages/")))
(defvar my/packages-to-install '(ox-hugo))
(defun my/designate-package-site (site)
(message "Designating package site %s => %s" (car site) (cdr site))
(add-to-list 'package-archives site t))
(defun my/designate-package-sites ()
(message "Designating package sites")
(mapcar #'my/designate-package-site my/package-archives))
(defun my/install-package (pkg)
(message "Installing package %s" pkg)
(ignore-errors (package-install pkg)))
(when (locate-library "package")
(require 'package)
(my/designate-package-sites)
(package-initialize)
(unless package-archive-contents (package-refresh-contents))
(mapcar #'my/install-package my/packages-to-install))
(defun my/batch-ox-hugo-file (file)
(message "Exporting org subtrees to hugo from %s" file)
(let ((all-subtrees t)
(any-visibility nil))
(with-current-buffer (find-file-noselect file)
(org-hugo-export-wim-to-md all-subtrees any-visibility))))
(defun my/batch-ox-hugo-directory (directory)
(message "Exporting all org subtrees in all files in %s" directory
(let ((default-directory (expand-file-name directory)))
(mapcar #'my/batch-ox-hugo-file
(file-expand-wildcards "*.org")))))
(my/batch-ox-hugo-directory default-directory)
The execution environment where I developed this is Emacs 28.2 on FreeBSD 13.1.
I haven't tried it out with Github Actions yet, but that's my next step.

Related

Emacs Org Mode Site: Open External Links in new tab

I'm in the process of remaking my website so that I can write the content of my website in org files.
I would like that external links would be opened in a new tab, but internal links, such as those in the automatically generated table of contents, must not.
I'd rather avoid having to resort to the following kind of solution:
+
#+BEGIN_EXPORT html
Site
#+END_EXPORT
+
#+BEGIN_EXPORT html
Repo
#+END_EXPORT
I'd really prefer that I could create links the usual org mode way.
Does anyone know of a way to do this? Thank you.
P.S. I suspect this isn't very relevant but, in case it clarifies anything, I'm building my site using this code in a .el file:
(require 'package)
(setq package-user-dir (expand-file-name "./.pakages"))
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("elpa" . "https://elpa.gnu.org/packages/")))
;; Initialize the package system
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
;; Install dependencies
(package-install 'htmlize)
;; Load the publishing system
(require 'ox-publish)
(setq org-html-validation-link nil ;; Don't show validation link
org-html-head-include-spcript nil ;; Use our own scripts
org-html-head-include-default-style nil) ;; Use our own styles
;; org-html-head "<link rel=\"stylesheet\" href=\"https://cdn.simplecss.org/simple.min.css\" />")
(defun read-file (filename)
(save-excursion
(let ((new (get-buffer-create filename)) (current (current-buffer)))
(switch-to-buffer new)
(insert-file-contents filename)
(mark-whole-buffer)
(let ((contents (buffer-substring (mark) (point))))
(kill-buffer new)
(switch-to-buffer current)
contents))))
;; Define the publishing project
(setq org-publish-project-alist
(list
(list "org-pages"
:recursive nil
:base-directory "./content"
:base-extension "org"
:publishing-directory "./public"
:publishing-function 'org-html-publish-to-html
:exclude ".*\~"
:with-author nil ;; Don't include author name
:with-creator nil ;; Don't include Emacs and Org versions in footer
:with-toc nil ;; Include table of contents
:section-numbers nil ;; Don't include section numbers
:time-stamp-file nil ;; Don't include time stamp in file
:html-preamble (read-file "./layout/preamble.html")
:auto-sitemap nil)
(list "blog-content"
:recursive t
:base-directory "./content/blog"
:base-extension "org"
:publishing-directory "./public/blog"
:publishing-function 'org-html-publish-to-html
:exclude ".*\~"
:with-author nil ;; Don't include author name
:with-creator nil ;; Don't include Emacs and Org versions in footer
:with-toc t ;; Include table of contents
:section-numbers nil ;; Don't include section numbers
:time-stamp-file nil ;; Don't include time stamp in file
:html-preamble (read-file "./layout/preamble.html")
:auto-sitemap t
:sitemap-filename "blog-archive.org"
:sitemap-title "Blog Posts"
:sitemap-sort-files 'anti-chronologically
:sitemap-style 'list)
(list "static"
:recursive t
:base-directory "./content"
:exclude ".*\~"
:base-extension "css\\|js\\|html\\|png\\|jpg\\|svg\\|webp\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
:publishing-directory "./public"
:publishing-function 'org-publish-attachment)
))
;; Generate the site output
(org-publish-all t)
(message "Build complete!")

Cannot open new frames with undo-tree installed

I use undo-tree 0.6.5 (from Elpa), and it works quite well most of the time. However, if I have not yet called C-x-u on a buffer, then from this buffer I can't open a new frame. If I do C-x-5-2, Emacs opens the `Backtrace buffer with this:
Debugger entered--Lisp error: (wrong-type-argument undo-tree nil)
signal(wrong-type-argument (undo-tree nil))
undo-tree-current(nil)
(undo-tree-node-previous (undo-tree-current buffer-undo-tree))
(and undo-tree-mode (not buffer-read-only) (not (eq t buffer-undo-list)) (undo-tree-node-previous (undo-tree-current buffer-undo-tree)))
x-create-frame(((visibility) (vertical-scroll-bars . left) (reverse . t)))
x-create-frame-with-faces(((vertical-scroll-bars . left) (reverse . t)))
#f(compiled-function (params) #<bytecode 0x1fdd4b1bc7bf>)(((vertical-scroll-bars . left) (reverse . t)))
apply(#f(compiled-function (params) #<bytecode 0x1fdd4b1bc7bf>) ((vertical-scroll-bars . left) (reverse . t)))
frame-creation-function(((vertical-scroll-bars . left) (reverse . t)))
make-frame()
make-frame-command()
funcall-interactively(make-frame-command)
call-interactively(make-frame-command nil nil)
command-execute(make-frame-command)
Then, I do C-x-u so the undo-tree buffer related to that buffer is created, and from then on I can create other frames.
Is there a workaround for this?
edit: it also prevents the use of menus. When I try to click on any menu item, the same message shows up.
edit: opening Emacs with this minimalistic startup file gives the same error:
(add-to-list 'load-path
"~/.emacs.d/elpa/undo-tree-0.6.5")
(require 'undo-tree)
(global-undo-tree-mode)
(setq debug-on-error t)
Okay, so I got it working. I was using the ELPA version of undo-tree, which is version 0.6.5. So a couple of days ago I noticed that the developer has a new version in his git repository, 0.6.6. I installed it locally and the problem was gone!
First, get a copy of the git repository:
$ cd ~/.emacs.d
$ git clone http://www.dr-qubit.org/git/undo-tree.git
Then add this to your Emacs config:
(load "~/.emacs.d/undo-tree/undo-tree.el")
(require 'undo-tree)
(global-undo-tree-mode)

in Emacs, how to open file in external program without errors?

I use the following code to direct Emacs to open PDF files using an external application:
(require 'openwith)
'(openwith-associations (quote (("\\.skim\\'" "open" (file)) ("\\.pdf\\'" "open" (file)))))
(openwith-mode t)
When I visit a PDF file, it successfully opens the file in my external program, but it also gives me errors and a backtrace:
Debugger entered--Lisp error: (error "Opened Foundation - Isaac Asimov.pdf in external program")
signal(error ("Opened Foundation - Isaac Asimov.pdf in external program"))
error("Opened %s in external program" "Foundation - Isaac Asimov.pdf")
openwith-file-handler(insert-file-contents "/Users/jay/iBooks/Books/Foundation - Isaac Asimov.pdf" t nil nil nil)
insert-file-contents("~/iBooks/Books/Foundation - Isaac Asimov.pdf" t)
byte-code("\302\303 \302\"\210)\302\207" [inhibit-read-only filename t insert-file-contents] 3)
find-file-noselect-1(#<killed buffer> "~/iBooks/Books/Foundation - Isaac Asimov.pdf" nil nil "~/Library/Containers/com.apple.BKAgentService/Data/Documents/iBooks/Books/Foundation - Isaac Asimov.pdf" (21490564 16777218))
find-file-noselect("/Users/jay/iBooks/Books/Foundation - Isaac Asimov.pdf" nil nil nil)
find-file("/Users/jay/iBooks/Books/Foundation - Isaac Asimov.pdf")
mapc(find-file ("/Users/jay/iBooks/Books/Foundation - Isaac Asimov.pdf"))
helm-find-many-files("/Users/jay/iBooks/Books/Foundation - Isaac Asimov.pdf")
apply(helm-find-many-files "/Users/jay/iBooks/Books/Foundation - Isaac Asimov.pdf")
How do I open files in external applications without throwing errors?
My recommendation would be to use start-process in conjunction with dired-mode to open files in external applications.
Xah Lee has written short, yet effective, function to handle opening files in the external default application set up on the OS: http://ergoemacs.org/emacs/emacs_dired_open_file_in_ext_apps.html
(defun xah-open-in-external-app (&optional file)
"Open the current file or dired marked files in external app.
The app is chosen from your OS's preference."
(interactive)
(let ( doIt
(myFileList
(cond
((string-equal major-mode "dired-mode") (dired-get-marked-files))
((not file) (list (buffer-file-name)))
(file (list file)))))
(setq doIt (if (<= (length myFileList) 5)
t
(y-or-n-p "Open more than 5 files? ") ) )
(when doIt
(cond
((string-equal system-type "windows-nt")
(mapc (lambda (fPath) (w32-shell-execute "open" (replace-regexp-in-string "/" "\\" fPath t t)) ) myFileList))
((string-equal system-type "darwin")
(mapc (lambda (fPath) (shell-command (format "open \"%s\"" fPath)) ) myFileList) )
((string-equal system-type "gnu/linux")
(mapc (lambda (fPath) (let ((process-connection-type nil)) (start-process "" nil "xdg-open" fPath)) ) myFileList) ) ) ) ) )
I use something similar (which can be viewed at the following Github link), but it is not as straight forward as the function written by Xah Lee: https://github.com/lawlist/dired-read-file-name/blob/master/dired-read-file-name.el
If the path to the file is in the buffer, I save it with M-w then invoke shell-command and call xdg-open C-y. This will yank the path to the file previously saved and opens it with the associated program. xdg-open takes care of finding the right program to open that file (screenshots).
In a dired buffer, browse-url-of-dired-file ("ask a WWW browser to display the file named on this line" - bound to W by default for me) opened a .csv file in Excel & a .md file in MacDown (both the OS default for those filetypes).
This is good enough for me, I might try to work out how to do it for the current buffer file some time.
(macOS Monterey 12.6.2, Emacs 28.2)

Installing el-get for managing packages in Emacs 24.3

The instructions for installing el-get say the following:
;; Copy/paste this code into your *scratch* buffer,
;; hit C-j, and you have a working el-get.
(url-retrieve
"https://raw.github.com/dimitri/el-get/master/el-get-install.el"
(lambda (s)
(goto-char (point-max))
(eval-print-last-sexp)))
When I do so, a buffer called *Backtrace* opens up in debugger-mode with the following contents:
Debugger entered--Lisp error: (void-variable closed)
eval(closed nil)
eval-last-sexp-1(t)
eval-last-sexp(t)
eval-print-last-sexp()
(lambda (s) (goto-char (point-max)) (eval-print-last-sexp))(nil)
apply((lambda (s) (goto-char (point-max)) (eval-print-last-sexp)) nil)
url-http-activate-callback()
url-http-content-length-after-change-function(589 3952 3363)
url-http-generic-filter(#<process raw.github.com> ";;; el-get-install.el --- installer for the lazy
;;
;; Copyright (C) 2010 Dimitri Fontaine
;;
;; Author: Dimitri Fontaine <dim#tapoueh.org>
;; URL: http://www.emacswiki.org/emacs/el-get.el
;; Created: 2010-06-17
;; Keywords: emacs package elisp install elpa git git-svn bzr cvs apt-get fink http http-tar
;; Licence: WTFPL, grab your copy here: http://sam.zoy.org/wtfpl/
;;
;; This file is NOT part of GNU Emacs.
;;
;; bootstrap your el-get installation, the goal is then to use el-get to
;; update el-get.
;;
;; So the idea is that you copy/paste this code into your *scratch* buffer,
;; hit C-j, and you have a working el-get.
(let ((el-get-root
(file-name-as-directory
(or (bound-and-true-p el-get-dir)
(concat (file-name-as-directory user-emacs-directory) \"el-get\")))))
(when (file-directory-p el-get-root)
(add-to-list 'load-path el-get-root))
;; try to require el-get, failure means we have to install it
(unless (require 'el-get nil t)
(unless (file-directory-p el-get-root)
(make-directory el-get-root t))
(let* ((package \"el-get\")
(buf (switch-to-buffer \"*el-get bootstrap*\"))
(pdir (file-name-as-directory (concat el-get-root package)))
(git (or (executable-find \"git\")
(error \"Unable to find `git'\")))
(url (or (bound-and-true-p el-get-git-install-url)
\"http://github.com/dimitri/el-get.git\"))
(default-directory el-get-root)
(process-connection-type nil) ; pipe, no pty (--no-progress)
;; First clone el-get
(status
(call-process
git nil `(,buf t) t \"--no-pager\" \"clone\" \"-v\" url package)))
(unless (zerop status)
(error \"Couldn't clone el-get from the Git repository: %s\" url))
;; switch branch if we have to
(let* ((branch (cond
;; Check if a specific branch is requested
((bound-and-true-p el-get-install-branch))
;; Check if master branch is requested
((boundp 'el-get-master-branch) \"master\")
;; Read the default branch from the el-get recipe
((plist-get (with-temp-buffer
(insert-file-contents-literally
(expand-file-name \"recipes/el-get.rcp\" pdir))
(read (current-buffer)))
:branch))
;; As a last resort, use the master branch
(\"master\")))
(remote-branch (format \"origin/%s\" branch))
(default-directory pdir)
(bstatus
(if (string-equal branch \"master\")
0
(call-process git nil (list buf t) t \"checkout\" \"-t\" remote-branch))))
(unless (zerop bstatus)
(error \"Couldn't `git checkout -t %s`\" branch)))
(add-to-list 'load-path pdir)
(load package)
(let ((el-get-default-process-sync t) ; force sync operations for installer
(el-get-verbose t)) ; let's see it all
(el-get-post-install \"el-get\"))
(unless (boundp 'el-get-install-skip-emacswiki-recipes)
(el-get-emacswiki-build-local-recipes))
(with-current-buffer buf
(goto-char (point-max))
(insert \"\
Congrats, el-get is installed and ready to serve!\")))))
closed
")
Do I take that there is an error in the file https://raw.github.com/dimitri/el-get/master/el-get-install.el ? Or is there anything else that I have to setup to get such a script working?
Somehow the downloaded file gets a closed line appended, which isn't present in the original file - not sure why, it doesn't happen for me. It's visible at the very end of the backtrace.
You could copy the entire el-get-install.el file, paste into *scratch* and eval that with C-j instead.

ELPA/Marmalade reports "cannot open load file" for ~/.emacs.d/elpa/archives/-pkg

I have installed Marmalade and downloaded some interesting packages. But now, when I start Emacs I get this error:
Cannot open load file: c:/Documents and Settings/Carlos/Datos de programa/.emacs.d/elpa/archives/-pkg
If I use --debug-init, I get:
Debugger entered--Lisp error: (file-error "Cannot open load file" "c:/Documents and Settings/Carlos/Datos de programa/.emacs.d/elpa/archives/-pkg")
load("c:/Documents and Settings/Carlos/Datos de programa/.emacs.d/elpa/archives/-pkg" nil t)
(if (file-directory-p pkg-dir) (load (concat pkg-dir ... "-pkg") nil t))
(let ((pkg-dir ...)) (if (file-directory-p pkg-dir) (load ... nil t)))
package-load-descriptor("c:/Documents and Settings/Carlos/Datos de programa/.emacs.d/elpa/" "archives")
(lambda (name) (package-load-descriptor dir name))("archives")
mapc((lambda (name) (package-load-descriptor dir name)) ("anything-1.287" "anything- complete-1.86" "anything-config-0.4.1" "archive-contents" "archive-contents~" "archives" "auto-indent-mode-0.35" "builtin-packages" "builtin-packages~" "clojure-mode-1.7.1" "clojurescript-mode-0.5" "coffee-mode-0.3.0" "color-file-completion-1.0.1" "color-theme-6.6.1" "color-theme-eclipse-0.0.2" "color-theme-github-0.0.3" "color-theme-railscasts-0.0.2" "color-theme-twilight-0.1" "css-mode-1.0" "drag-stuff-0.0.3" "evernote-mode-0.41" "find-file-in-project-2.0" "flymake-coffee-0.4" "flymake-haml-0.5" "flymake-ruby-0.4" "flymake-shell-0.5" "haml-mode-3.0.14" "highlight-parentheses-1.0.1" "html-script-src-0.0.2" "inf-ruby-2.1" "js-comint-0.0.1" "js2-mode-20090814" "lua-mode-20100617" "package.el" "package.el~" "project-local-variables-0.2" "ruby-compilation-0.7" "ruby-electric-1.1" "ruby-mode-1.1" "slime-20100404" "tabbar-2.0.1" "tabbar-ruler-0.2" "yasnippet-0.6.1" "yasnippet-bundle-0.6.1" "zenburn-1.8"))
(if (file-directory-p dir) (mapc (lambda ... ...) (directory-files dir nil "^[^.]")))
(lambda (dir) (if (file-directory-p dir) (mapc ... ...)))("c:/Documents and Settings/Carlos/Datos de programa/.emacs.d/elpa/")
mapc((lambda (dir) (if (file-directory-p dir) (mapc ... ...))) ("c:/Documents and Settings/Carlos/Datos de programa/.emacs.d/elpa/" "/usr/share/emacs/site-lisp/elpa/"))
package-load-all-descriptors()
package-initialize()
(progn (package-initialize))
(if (load (expand-file-name "~/.emacs.d/elpa/package.el")) (progn (package-initialize)))
(when (load (expand-file-name "~/.emacs.d/elpa/package.el")) (package-initialize))
eval-buffer(#<buffer *load*> nil "c:/Documents and Settings/Carlos/Datos de programa/.emacs" nil t) ; Reading at buffer position 9019
load-with-code-conversion("c:/Documents and Settings/Carlos/Datos de programa/.emacs" "c:/Documents and Settings/Carlos/Datos de programa/.emacs" t t)
load("~/.emacs" t t)
#[nil "\205\264
This file doesn't exist. I've tried searching for this problem with Google but I didn't find anything.
Easy. For whatever reason, the package.el you're now using is the "classic" version from http://tromey.com/elpa/package.el. It's wildly incompatible with recent versions of package.el. How you managed to install Marmalade packages using that version, I don't know; you must have had a different version of package.el when you installed those packages, perhaps because you were using a newer Emacs at the time.
The fix is to use the version bundled with your Emacs (if it's new enough to have one), or to replace your ~/.emacs.d/elpa/package.el with this version instead, as described in the Marmalade instructions.
I've stumbled upon this question while trying to solve a similar problem. In my case, forcing package-initialize have solved the problem:
;; init.el
(require 'package)
(package-initialize)
Even though I did not read the source code for package.el, I believe some kind of laziness in package.el is cousing the problem. Athough this is and old question, I wanted to answer, in case someone else need some help.
For more information on Emacs start-up, see http://www.gnu.org/software/emacs/manual/html_node/elisp/Startup-Summary.html.
Adding a file, not directory, using touch ~/.emacs.d/elpa/archives/-pkg solved it for me.
I think it may just go away if you manually create a directory at:
c:/Documents and Settings/Carlos/Datos de programa/.emacs.d/elpa/archives/-pkg
In my case I had to add this directive to tell emacs where it can find the files required:
First this line
(add-to-list 'load-path "~/.emacs.d/")
And the required package ...
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t)
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))