Pankaj Jangid writes: [...] > Same org file has multiple tables, so I am asking for “Table Name”. I > want to do two improvements: > > 1. When asking for table name, I want to offer all the table names in > the file as completion options.
You could collect names with something like (require 'subr-x) (let (names) (org-table-map-tables (lambda () (when-let ((name (org-element-property :name (org-element-at-point)))) (push name names))) 'quiet) (nreverse names)) and then pass those as the collection to completing-read. > 2. Current table at point as default You could get that with (and (org-at-table-p) (save-excursion (goto-char (org-table-begin)) (org-element-property :name (org-element-at-point)))) and pass that as the default for completing-read. > 3. I want to run the function from command line. Like, > > --8<---------------cut here---------------start------------->8--- > emacs --batch enet_2021_22.org -l enet.el --eval="(enet-export > \"APR2021\")" > --8<---------------cut here---------------end--------------->8--- > > Do I need to change the (interactive...) part in any way to enable > this? I think that'd be the cleanest way, yes. You could change (interactive "MTable Name: ") into (interactive (list (completing-read ...)))