[O] Partial word emphasis suggestion

2014-03-01 Thread 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,




[O] How to force markup without spaces

2012-11-18 Thread cinsky

Hi,

AFAIK, if the markup syntax (=code=, *bold*, ..) is directly followed
by non-whitespace characters, then it will not be marked-up:

   =hello=there
   /not/italic

This may be right decision on English text, but in some languages, the
postposition (grammar) will be postfixed without spaces into the
previous noun, so it will be the trouble.  (Following text contains
Korean characters in UTF-8, you may need additional korean font to
read properly)

   =printf=는
   =bold=로
   =철수=는

I'm sure that some other languages will have same problem
(e.g. Japanese or Chinese).

Is there any way to force mark-up on this situation?

If this pattern cannot be implemented easily, how about to introduce
new escaping character to prevent to insert whitespace between
marked-up text and the following postfix text?  For example:

  =printf=\is  = rendered in HTML: codeprintf/codeis
  *bold*\asdf  = rendered in HTML: bbold/basdf
  /철수/\는= rendered in HTML: i철수/i는

I can't say the above solution is well-designed, but I'm sure that
you'll get the point.

Thanks.

-- 
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Korean Ver: http://www.cinsk.org/cfaqs/