Skip to content

Commit 17f7709

Browse files
committed
Add emacs config sourcing to export
This fixes a bug where just calling "--batch" does not source your config. This commit hardcodes to "~/.emacs.d/init.el" which really should be dynamic in settings/config. Just not sure how to do that.
1 parent 1acead1 commit 17f7709

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

DOCS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ Determine if blank line should be prepended when:
245245
* Adding heading via `org_meta_return` and `org_insert_*` mappings
246246
* Adding a list item via `org_meta_return`
247247

248+
#### **emacs_config**
249+
*type*: `table`<br />
250+
*default value*: `{ executable_path = 'emacs', configure_path='$HOME/.emacs.d/init.el' }`<br />
251+
Set configuration for your emacs. This is useful for having the emacs export properly pickup your emacs config and plugins.
252+
248253
### Agenda settings
249254

250255
#### **org_deadline_warning_days**

doc/orgmode.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ CONTENTS *orgmode-content
2626
1.2.1.15. org_custom_exports..............|orgmode-org_custom_exports|
2727
1.2.1.16. org_time_stamp_rounding_minutes.|orgmode-org_time_stamp_rounding_minutes|
2828
1.2.1.17. org_blank_before_new_entry.|orgmode-org_blank_before_new_entry|
29+
1.2.1.18. emacs_config..........................|orgmode-emacs_config|
2930
1.2.2. Agenda settings...........................|orgmode-agenda_settings|
3031
1.2.2.1. org_deadline_warning_days.|orgmode-org_deadline_warning_days|
3132
1.2.2.2. org_agenda_span.....................|orgmode-org_agenda_span|
@@ -430,6 +431,12 @@ Determine if blank line should be prepended when:
430431
* Adding heading via `org_meta_return` and `org_insert_*` mappings
431432
* Adding a list item via `org_meta_return`
432433

434+
EMACS_CONFIG *orgmode-emacs_config*
435+
436+
type: `table`
437+
default value: `{ executable_path = 'emacs', configure_path='$HOME/.emacs.d/init.el' }`
438+
Set configuration for your emacs. This is useful for having the emacs export properly pickup your emacs config and plugins.
439+
433440
AGENDA SETTINGS *orgmode-agenda_settings*
434441

435442
ORG_DEADLINE_WARNING_DAYS *orgmode-org_deadline_warning_days*

lua/orgmode/config/defaults.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,8 @@ return {
152152
around_subtree_from_root = 'OR',
153153
},
154154
},
155+
emacs_config = {
156+
executable_path = 'emacs',
157+
config_path = '$HOME/.emacs.d/init.el',
158+
},
155159
}

lua/orgmode/export/init.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,18 @@ end
108108
function Export.emacs(format, extension)
109109
local file = vim.api.nvim_buf_get_name(0)
110110
local target = vim.fn.fnamemodify(file, ':p:r') .. '.' .. extension
111-
if vim.fn.executable('emacs') ~= 1 then
111+
local emacs = config.emacs_config.executable_path
112+
local emacs_config_path = config.emacs_config.config_path
113+
if vim.fn.executable(emacs) ~= 1 then
112114
return utils.echo_error('emacs executable not found. Make sure emacs is in $PATH.')
113115
end
114116

115117
local cmd = {
116-
'emacs',
118+
emacs,
117119
'-nw',
118120
'--batch',
121+
'--load',
122+
emacs_config_path,
119123
string.format('--visit=%s', file),
120124
string.format('--funcall=%s', format),
121125
}

0 commit comments

Comments
 (0)