--text follows this line-- I wrote a custom function that let me preview a Markdown buffer in Marked, which utilizes shell-quote-argument to export the path to the file being edited in Emacs to Marked.app. It works well until it encounters file names or paths with Chinese characters. The Chinese characters are wrongfully escaped. For example: (shell-quote-argument "/Users/user/中文目录/中文file.txt") evals to "/Users/user/\\中\\文\\目\\录/\\中\\文file.txt" The shell-quote-argument function yields the same output under a new emacs instance started with `emacs -q`, so this should not be related to my configuration. A quick look of the function in question shows that it just escapes all non-ASCII characters, and the escaped Chinese characters cannot be correctly recognized by either bash or zsh. Shouldn't the regexp in the function be more discriminative and recognize, say, unicode characters allowed in file names and paths? I think very few people use (or know) any shell that recognize a unicode smiley (U+263A) as a command, but many use a language they speak to name files. In GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2013-03-13 on bob.porkrind.org Windowing system distributor `Apple', version 10.3.1187 Configured using: `configure '--host=x86_64-apple-darwin' '--build=i686-apple-darwin' '--with-ns' 'build_alias=i686-apple-darwin' 'host_alias=x86_64-apple-darwin' 'CC=gcc -mmacosx-version-min=10.7 -isystem /Users/david/Xcode-10.7_4.5.2/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/ -F/Users/david/Xcode-10.7_4.5.2/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks'' Important settings: locale-coding-system: nil default enable-multibyte-characters: t Major mode: EL Minor modes in effect: rainbow-mode: t rainbow-delimiters-mode: t elisp-slime-nav-mode: t guru-mode: t global-linum-mode: t linum-mode: t evil-mode: t evil-local-mode: t erc-truncate-mode: t erc-track-mode: t erc-spelling-mode: t global-flycheck-mode: t flycheck-mode: t which-function-mode: t winner-mode: t global-undo-tree-mode: t undo-tree-mode: t eldoc-mode: t whitespace-mode: t projectile-global-mode: t projectile-mode: t flyspell-mode: t flx-ido-mode: t ido-ubiquitous-mode: t volatile-highlights-mode: t global-hl-line-mode: t show-paren-mode: t shell-dirtrack-mode: t recentf-mode: t savehist-mode: t smartparens-global-mode: t smartparens-mode: t global-auto-revert-mode: t delete-selection-mode: t prelude-global-mode: t prelude-mode: t tooltip-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t size-indication-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t Recent input: ( ) C-x C-e C-h e s-c q C-x b C-a C-k C-k C-k C-x C-s s-c o k e k e j 可 见 , C-x C-s C-x 1 : w M-x C-h f p r e v i e w - C-h f s h e l l - q u o t M-x r e p o r t Recent messages: Saving file /Users/snakehsu/Dropbox/Office Work/OngoingProjects/HFC削减对策研究/01-北美提案研究/03-批评分析/北美提案评价与分析.md... Wrote /Users/snakehsu/Dropbox/Office Work/OngoingProjects/HFC削减对策研究/01-北美提案研究/03-批评分析/北美提案评价与分析.md Saving file /Users/snakehsu/Dropbox/Office Work/OngoingProjects/HFC削减对策研究/01-北美提案研究/03-批评分析/北美提案评价与分析.md... Wrote /Users/snakehsu/Dropbox/Office Work/OngoingProjects/HFC削减对策研究/01-北美提案研究/03-批评分析/北美提案评价与分析.md (No changes need to be saved) Type C-w C-o to delete the help window. Type "q" in help window to restore its previous buffer. uncompressing subr.el.gz...done compressing flycheck-subr.el.gz...done compressing subr.el.gz...done Load-path shadows: /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org hides /Applications/Emacs.app/Contents/Resources/lisp/org/org /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-w3m hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-w3m /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-timer hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-timer /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-table hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-table /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-src hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-src /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-rmail hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-rmail /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-protocol hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-protocol /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-plot hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-plot /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-pcomplete hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-pcomplete /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-mouse hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-mouse /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-mobile hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-mobile /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-mhe hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-mhe /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-macs hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-macs /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-loaddefs hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-loaddefs /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-list hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-list /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-irc hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-irc /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-install hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-install /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-inlinetask hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-inlinetask /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-info hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-info /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-indent hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-indent /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-id hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-id /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-habit hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-habit /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-gnus hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-gnus /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-footnote hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-footnote /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-feed hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-feed /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-faces hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-faces /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-eshell hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-eshell /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-entities hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-entities /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-element hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-element /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-docview hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-docview /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-datetree hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-datetree /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-ctags hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-ctags /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-crypt hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-crypt /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-compat hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-compat /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-colview hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-colview /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-clock hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-clock /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-capture hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-capture /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-bibtex hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-bibtex /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-bbdb hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-bbdb /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-attach hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-attach /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-archive hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-archive /Users/snakehsu/.emacs.d/elpa/org-20130724.137/org-agenda hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-agenda /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-tangle hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-tangle /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-table hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-table /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-sqlite hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-sqlite /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-sql hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-sql /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-shen hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-shen /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-sh hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-sh /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-screen hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-screen /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-scheme hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-scheme /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-scala hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-scala /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-sass hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-sass /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-ruby hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-ruby /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-ref hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-ref /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-R hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-R /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-python hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-python /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-plantuml hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-plantuml /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-picolisp hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-picolisp /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-perl hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-perl /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-org hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-org /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-octave hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-octave /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-ocaml hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-ocaml /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-mscgen hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-mscgen /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-maxima hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-maxima /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-matlab hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-matlab /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-lob hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-lob /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-lisp hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-lisp /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-lilypond hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-lilypond /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-ledger hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-ledger /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-latex hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-latex /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-keys hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-keys /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-js hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-js /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-java hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-java /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-io hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-io /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-haskell hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-haskell /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-gnuplot hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-gnuplot /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-fortran hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-fortran /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-exp hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-exp /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-eval hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-eval /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-emacs-lisp hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-emacs-lisp /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-dot hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-dot /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-ditaa hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-ditaa /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-css hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-css /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-comint hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-comint /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-clojure hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-clojure /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-calc hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-calc /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-C hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-C /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-awk hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-awk /Users/snakehsu/.emacs.d/elpa/org-20130724.137/ob-asymptote hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-asymptote /Users/snakehsu/.emacs.d/elpa/magit-20130722.239/.dir-locals hides /Applications/Emacs.app/Contents/Resources/lisp/gnus/.dir-locals Features: (shadow sort mail-extr emacsbug message rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mail-utils jka-compr helm-imenu vc-git debug executable markdown-mode ffap url-parse url-vars rainbow-mode rainbow-delimiters elisp-slime-nav guru-mode color the-org-mode-expansions org org-macro org-footnote org-pcomplete org-list org-faces org-entities noutline outline ob-emacs-lisp ob ob-tangle org-src ob-ref ob-lob ob-table ob-keys ob-exp ob-comint ob-core ob-eval org-compat org-macs org-loaddefs cal-menu calendar cal-loaddefs linum evil evil-integration evil-maps evil-commands evil-types evil-search evil-ex evil-macros evil-repeat evil-states evil-core evil-common rect evil-digraphs evil-vars zen-and-art-theme prelude-xml nxml-mode-expansions html-mode-expansions rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph nxml-enc xmltok prelude-scheme prelude-perl prelude-org prelude-js prelude-erc erc-truncate erc-track erc-match erc-autoaway erc-spelling erc-notify erc-networks erc-log erc-goodies erc erc-backend erc-compat prelude-emacs-lisp prelude-lisp prelude-c prelude-programming flycheck find-func help-mode rx which-func imenu prelude-osx exec-path-from-shell prelude-global-keybindings key-chord prelude-editor winner undo-tree diff esh-var esh-io esh-cmd esh-opt esh-ext esh-proc esh-arg eldoc esh-groups eshell esh-module esh-mode esh-util re-builder whitespace midnight ediff-merg ediff-diff ediff-wind ediff-help ediff-util ediff-mult ediff-init ediff dired-x helm-projectile helm-buffers helm-grep helm-regexp helm-elscreen helm-utils dired helm-locate helm-config helm-aliases helm-misc helm projectile grep compile s bookmark pp expand-region text-mode-expansions er-basic-expansions expand-region-custom expand-region-core flyspell ispell smex flx-ido flx ido-ubiquitous ido etags volatile-highlights hl-line paren windmove tramp-cache tramp-sh tramp tramp-compat auth-source gnus-util mm-util mail-prsvr password-cache tramp-loaddefs shell pcomplete comint ansi-color ring format-spec recentf tree-widget wid-edit savehist saveplace uniquify diminish smartparens-config smartparens warnings autorevert delsel prelude-mode easy-mmode edmacro kmacro prelude-core advice help-fns advice-preload dash thingatpt prelude-ui zenburn-theme prelude-packages ace-jump-mode-autoloads ack-and-a-half-autoloads color-theme-autoloads diminish-autoloads elisp-slime-nav-autoloads evil-paredit-autoloads evil-autoloads exec-path-from-shell-autoloads expand-region-autoloads flx-ido-autoloads flx-autoloads flycheck-autoloads gist-autoloads gh-autoloads eieio byte-opt bytecomp byte-compile cconv git-auto-commit-mode-autoloads git-commit-mode-autoloads gitconfig-mode-autoloads gitignore-mode-autoloads grizzl-autoloads guru-mode-autoloads helm-projectile-autoloads helm-autoloads ido-ubiquitous-autoloads ir-black-theme-autoloads key-chord-autoloads logito-autoloads magit-autoloads markdown-mode-autoloads mustache-mode-autoloads org-trello-autoloads org-autoloads info easymenu paredit-autoloads pcache-autoloads php-mode-autoloads powerline-autoloads powerline powerline-separators powerline-themes projectile-autoloads rainbow-delimiters-autoloads rainbow-mode-autoloads request-autoloads ruby-end-autoloads s-autoloads smartparens-autoloads dash-autoloads finder-inf smex-autoloads solarized-theme-autoloads undo-tree-autoloads volatile-highlights-autoloads yasnippet-autoloads zen-and-art-theme-autoloads zenburn-theme-autoloads zencoding-mode-autoloads package cl-macs gv cl cl-lib time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel ns-win tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process ns multi-tty emacs)