all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <moasen@zoho.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Toggle WikiLink on and off does not work?
Date: Thu, 17 Aug 2017 13:54:47 +0200	[thread overview]
Message-ID: <86pobuwgs8.fsf@zoho.com> (raw)
In-Reply-To: CAONhAouELN8WfydsNospi8F5pBDVK9OTxgBUcPbPcTqCH7p8rw@mail.gmail.com

Here is how I would write it, I think. It seems
to work at least when inserting or removing the
tag is concerned.

If it gets more complicated, you might want to
factor out the searches (the
`re-search-forward's) and put them into
a `let', then check the associated values if
they are nil or not (see the help for
re-search-forward how to make it not report an
error on no hit), and then move point to
(match-beginning 0) - but only if you feel the
need to, using re-search-forward "inline" if
you will is a fine way to do it as well.

See answer one for comments what I did.
Except for [[:alpha:]] which I didn't mention.

In answer two there are some other comments.
This is answer three :)

    (defun emacs-wiki-unlink-toggle ()
      (interactive)
      (save-excursion
        (if (looking-at "[[:space:]]")
            (goto-char (1- (re-search-forward "[[:alpha:]<]")))
          (goto-char (1+ (re-search-backward "[[:space:]]"))))
        (let*((nop "<nop>")
              (nop-len (length nop)))
          (if (looking-at nop)
              (delete-char nop-len)
            (insert nop)))))

-- 
underground experts united
http://user.it.uu.se/~embe8573




      parent reply	other threads:[~2017-08-17 11:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-16  8:55 Toggle WikiLink on and off does not work? Csányi Pál
2017-08-16 14:50 ` Emanuel Berg
2017-08-16 15:32   ` Emanuel Berg
2017-08-17  8:17   ` Csányi Pál
2017-08-17 11:42     ` Emanuel Berg
2017-08-17 18:53       ` Csányi Pál
2017-08-17 21:12         ` Emanuel Berg
2017-08-18  5:06           ` Csányi Pál
2017-08-19 14:13             ` Emanuel Berg
2017-08-19 14:41               ` Csányi Pál
2017-08-19 14:52                 ` Emanuel Berg
2017-08-19 15:15                   ` Csányi Pál
2017-08-17 11:54     ` Emanuel Berg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86pobuwgs8.fsf@zoho.com \
    --to=moasen@zoho.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.