[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Toggle WikiLink on and off does not work?

From: Csányi Pál
Subject: Re: Toggle WikiLink on and off does not work?
Date: Fri, 18 Aug 2017 07:06:31 +0200

2017-08-17 23:12 GMT+02:00 Emanuel Berg <>:
> Csányi Pál wrote:
>> It is all the same whether is a <nop> before
>> a CamelCase or is not there, the CamelCase
>> remain wikilink. I expect that, if a <nop> is
>> before a such CamelCase, like <nop>CamelCase
>> then it should turn into non-link. Right?
>> This turn thing does not works here.
> There is nothing specifically about CamelCase
> in that function!
> Can you give us a piece of code and tell where
> point is and what you want to happen when the
> function is invoked?

As you know, I am not who wrote this code down, but yason:

Toggle WikiLink on and off

Depending on the type of the text you write, you might be typing a lot
of CamelCase words that are, however, not links. Writing <nop> is
cumbersome after a few iterations, and sometimes you’ll have to remove
it again. Here’s a short function that toggles the current CamelCaps
word between wikilink and non-link:

  (defun emacs-wiki-unlink-toggle ()
    "Toggle <nop> string in the beginning of the current word, to un/make a
    word emacs-wiki link. The current word depends on the point: if the cursor
    is on a non-whitespace character, it's considered a word surrounded by
    whitespace. If the cursor is on a whitespace character, the next word is
    looked up. This way addressing a word works intuitively after having
    arrived on the spot using forward-word."
      (if (looking-at "[[:space:]]")
          (goto-char (- (re-search-forward "[A-Za-z<]") 1))
          (goto-char (+ (re-search-backward "[[:space:]]") 1)))
      (if (looking-at "<nop>")
        (delete-char 5)
        (insert "<nop>"))))

I hook it up to C-n with this:

  (add-hook 'emacs-wiki-mode-hook
    '(lambda () (local-set-key "\C-c\C-n" 'emacs-wiki-unlink-toggle)))


> This issue is a bit trivial - why not just
> type? - but OK, I sense it has a trivial
> solution as well where that function
> fails... :)

In Wiki Mode if one write down a CamelCase word, it turns
automatically in to wikilink.
I thought the code abowe was for turning off wikilink into non-link in
such case when one want to write down a CamelCase word in Wiki Mode,
but want it not to be a wikilink.

If this code write down by yason does this not, then what is it for??
What is the purpose of the <nop> at the start of such CamelCase word
in Wiki Mode then??

Best, Pali

reply via email to

[Prev in Thread] Current Thread [Next in Thread]