HDFql + Emacs + Org => Winning Combo


Add this to your init.el:

;; We assume that HDFqlCLI is in the path and that libHDFql.so is in

(defun org-babel-execute:hdfql (body params)
  "Execute a block of HDFql code with org-babel."
  (message "executing HDFql source code block")
   (format "HDFqlCLI --no-status --execute=\"%s\"" body) ""))

(push '("hdfql" . sql) org-src-lang-modes)

(add-to-list 'org-structure-template-alist '("hq" . "src hdfql"))

and enjoy this:


  1. Support for sessions (:session header argument)
  2. Fancier syntax highlighting
  3. VSCode extension
  4. Jupyter kernel

Dear Santa; it’s a long story…



Great to see this integration between HDFql and Emacs happening - thanks @gheber! :slight_smile:


@contact Do you have an (E)BNF grammar of HDFql somewhere? The language description in section 6 of your reference manual is pretty thorough, but is there a standalone grammar somewhere?



Sure - we just compiled an HDFql grammar based on section 6 from HDFql reference manual which can be found here (12.9 KB).

Hope it helps!


First experiment w/ font locking (Emacs-speak for syntax highlighting):

(defvar hdf5-keywords-re
     "chunked" "compact"
     "dataset" "dense" "directory" "dimension"
     "unlimited" "userblock size"


(defun hdfql-font-lock-add-keywords ()
  "Augment the sql mode font-lock keywords for HDFql"
  (if (fboundp 'font-lock-add-keywords)
	     'sql-mode `((,hdf5-keywords-re . font-lock-function-name-face)))
	     'sql-mode `((,hdf5-type-keywords-re . font-lock-type-face)))
	     'sql-mode `((,hdfql-keywords-re . font-lock-keyword-face)))

(add-hook 'sql-mode-hook
          '(lambda ()
             (setq font-lock-keywords-case-fold-search t)
 	         (font-lock-mode t)))

(setq major-mode 'hdfql-mode)
(setq mode-name "HDFql")

(defun hdfql-mode ()

(provide 'hdfql)

Seems to do the trick:



Another slight simplification. Just add this to .emacs or .emacs.d/init.el

;; HDFql support
(autoload 'hdfql-mode "hdfql" "Interact with HDF5 files via HDFql" t)

and put the attached hdfql.el into your load path.

Enjoy, G.

hdfql.el (2.2 KB)


Thanks for sharing this @gheber! Would it make sense to create a Git repository where the file could be stored/versioned? This would enable other people to contribute to its maintenance, including ourselves.


Yes! Check this out: https://github.com/HDFGroup/emacs



That’s great - thanks for sharing this! We will contribute to its maintenance whenever we add/change/remove keywords in HDFql.