From mboxrd@z Thu Jan 1 00:00:00 1970 From: cinsky@gmail.com Subject: Partial word emphasis suggestion Date: Sun, 02 Mar 2014 10:04:57 +0900 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJuq7-0007Qu-A0 for emacs-orgmode@gnu.org; Sat, 01 Mar 2014 20:05:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJuq1-0005OC-E1 for emacs-orgmode@gnu.org; Sat, 01 Mar 2014 20:05:11 -0500 Received: from mail-pd0-x235.google.com ([2607:f8b0:400e:c02::235]:55130) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJuq1-0005Ld-5p for emacs-orgmode@gnu.org; Sat, 01 Mar 2014 20:05:05 -0500 Received: by mail-pd0-f181.google.com with SMTP id p10so2266146pdj.26 for ; Sat, 01 Mar 2014 17:05:04 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: cinsky@gmail.com Dear Org-mode members, A couple of years ago, I asked how to emphasis partial word (e.g. =no-emphasis=on-subword=) without blank character, and someone pointed out this link: http://thread.gmane.org/gmane.emacs.orgmode/46197/focus=46263 Basically, it suggest to add unicode "word joiner" character (\u2060) in `org-emphasis-regexp-components' like this: (org-set-emph-re 'org-emphasis-regexp-components '(" \t('\"{\\\u2060" "- \t.,:!?;'\")}\\\u2060" " \t\r\n,\"'⁠" "." 1))) Some human languages (Korean, including CJK) uses lots of postfix components, so we need a partial word emphasis a lot. >From above link, I manually insert the word joiner character by binding a command that calls `insert-char', but it was too cumbersome. I made following minor mode, which inserts the word joiner if it detects the need. --BEGINNING-OF-SCRIPT-- (defun different-command-p (command name) "Return t iff COMMAND is a command and has different from NAME" (and (commandp command) (not (eq name command)) ;string-match name (symbol-name command))) command)) (defun call-next-command (keys not-this-command) "Interactively call the command that has a binding of KEYS, but not NOT-THIS-COMMAND" (let ((command (catch 'found (mapc (lambda (map) (let ((cmd (different-command-p (lookup-key map keys) not-this-command))) (when cmd (throw 'found cmd)))) (current-minor-mode-maps)) (or (different-command-p (lookup-key (current-local-map) keys) not-this-command) (different-command-p (lookup-key (current-global-map) keys) not-this-command))))) (when (commandp command) (call-interactively command)))) (defun org-insert-word-joiner-or-space () (interactive) (save-match-data (when (looking-back "\\([=/]\\)\\(.*\\)\\1\\([^[:space:]\u2060]+\\)" (line-beginning-position) 'greedy) ;; 2nd match => emphasised phrase (e.g. =code=) ;; 3rd match => partial word appended (save-excursion (goto-char (match-beginning 3)) (insert-char #x2060))) (call-next-command (this-command-keys-vector) 'org-insert-word-joiner-or-space))) (defvar org-wordjoin-mode-map (let ((map (make-sparse-keymap))) (define-key map [?\ ] 'org-insert-word-joiner-or-space) (define-key map [(control ?j)] 'org-insert-word-joiner-or-space) (define-key map [(control ?m)] 'org-insert-word-joiner-or-space) (define-key map [(tab)] 'org-insert-word-joiner-or-space) map) "Keymap for `org-wordjoin-mode'") (define-minor-mode org-wordjoin-mode "Enable automatic insertion of word joiner" nil " WordJoin" :keymap org-wordjoin-mode-map) --END-OF-SCRIPT-- Q1. Is there better way to do this? (esp. I think the regular expression in `looking-back' is not 100% compatible with org-mode's pattern for the emphasis. But I couldn't come up with better one.) Q2. If I remember correctly, I read from the mailing list that partial word emphasis will not be supported in org-mode. Is it possible to org-mode to include this kind of minor mode? If possible, I hope that some experts can come up with better implementation of this and include that in the official package. Or, at least insert "word joiner" character character in `org-emphasis-regexp-components' please. Thank you,