Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/emacs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var fs = require('fs-extra');
var tmp = require('tmp');
var path = require('path');
var retry = require('retry');
var md5 = require('md5');

// A variable to save current config.org.emacsclient info
var emacsclient = "emacsclient";
Expand Down Expand Up @@ -63,6 +64,11 @@ function update_server_file(hexo) {
return server_file;
}

// The file path of hexo-renderer-org may be too long for emacs --daemon, short it with md5
function get_server_name(hexo) {
return md5(get_server_file(hexo))
}

function get_server_file(hexo) {
return server_file || update_server_file(hexo);
}
Expand Down Expand Up @@ -140,7 +146,7 @@ function emacs_server_start(hexo)
// Remove triling garbages
emacs_lisp = fix_elisp(emacs_lisp);

var exec_args = ['-Q','--daemon=' + get_server_file(hexo), '--eval', emacs_lisp];
var exec_args = ['-Q','--daemon=' + get_server_name(hexo), '--eval', emacs_lisp];

var proc = child_process.spawn(config.org.emacs, exec_args, {
stdio: 'inherit' // emacs's htmlize package need tty
Expand Down Expand Up @@ -172,7 +178,7 @@ function emacs_server_stop(hexo)
if (!use_emacs_server)
return resolve();

var proc = child_process.spawn(emacsclient, ['-s', get_server_file(hexo), '-e', '(kill-emacs)'], {
var proc = child_process.spawn(emacsclient, ['-s', get_server_name(hexo), '-e', '(kill-emacs)'], {
// detached: true
});

Expand Down Expand Up @@ -207,7 +213,7 @@ function emacs_server_wait(hexo)
if (!use_emacs_server)
return resolve();

var proc = child_process.spawn(emacsclient, ['-s', get_server_file(hexo), '-e', '(message "ping")'], {
var proc = child_process.spawn(emacsclient, ['-s', get_server_name(hexo), '-e', '(message "ping")'], {
});

proc.on('exit', function(code) {
Expand Down Expand Up @@ -262,7 +268,7 @@ function emacs_client(hexo, data, callback)
// Remove triling garbages
emacs_lisp = fix_elisp(emacs_lisp);

var exec_args = ['-s', get_server_file(hexo), '-e', emacs_lisp];
var exec_args = ['-s', get_server_name(hexo), '-e', emacs_lisp];

// if (config.org.export_cfg != '')
// exec_args.splice(1,0,'--execute', config.org.export_cfg);
Expand Down
2 changes: 1 addition & 1 deletion lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function render_html(html, config) {
});

//reslove(get_content($));
reslove($.html());
reslove($.html({decodeEntities: false}));
});
}

Expand Down