* Partial word emphasis suggestion
@ 2014-03-02 1:04 cinsky
2014-03-17 2:04 ` Bastien
0 siblings, 1 reply; 2+ messages in thread
From: cinsky @ 2014-03-02 1:04 UTC (permalink / raw)
To: emacs-orgmode; +Cc: cinsky
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,
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Partial word emphasis suggestion
2014-03-02 1:04 Partial word emphasis suggestion cinsky
@ 2014-03-17 2:04 ` Bastien
0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2014-03-17 2:04 UTC (permalink / raw)
To: cinsky; +Cc: emacs-orgmode
Hi,
cinsky@gmail.com writes:
> Or, at least insert "word joiner" character character in
> `org-emphasis-regexp-components' please.
We will address this kind of shortcomings when reimplementing
the fontification engine of Org-mode (not anytime soon, though),
so for now you'll have to use the ad hoc solution of the minor
mode you shared.
Best,
--
Bastien
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-03-17 2:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-02 1:04 Partial word emphasis suggestion cinsky
2014-03-17 2:04 ` Bastien
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.