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:42:35 +0200	[thread overview]
Message-ID: <86tw16whck.fsf@zoho.com> (raw)
In-Reply-To: CAONhAouELN8WfydsNospi8F5pBDVK9OTxgBUcPbPcTqCH7p8rw@mail.gmail.com

Csányi Pál wrote:

> (define-key emacs-wiki-unlink-toggle "\C-\M-n")
>
> When I load the .emacs file with 'M-x
> load-file' command, I get message: Wrong number
> of arguments: define-key, 2

Here you use `C-h f define-key RET' to bring up
the help, where you see that the interface to
`define-key' is

    (define-key KEYMAP KEY DEF)

So it should be

    (define-key emacs-wiki-mode-map "\C-c\C-n" #'emacs-wiki-unlink-toggle)

The reason you do `require' before this is that
otherwise, there isn't any
`emacs-wiki-mode-map' to set!

> A want to add to this question more. Actually,
> with the previous setup the C-c C-n keybinding
> works

OK, yes, I admit I only got confused by that
hook solution with local-set-key. There are
many ways to set keys and naturally I'm the
most into my own ways. So if it works it works.

The reason hooks are considered less reliable
and are a tiny bit slower is that they execute
every time. So the functions there execute over
and over. It shouldn't really influence
the speed. Perhaps the interactive feel, if
your "feelings" are really fine turned.

However with require + define you do it once
and that's it. It is always what I try first
and most time it works. Sometimes it doesn't
work tho and without having digged into that
I guess when some subsection of a software
component is brought to life, it resets keys
that should have been left alone. Whenever that
happens, I still use define, I just enclose it
in a function and have that called from the
hook function. As in:

;; (setq erc-mode-hook nil)
(defun erc-mode-hook-f ()
  ; [...] some unrelated stuff cut for clarity
  (set-erc-keys) ; why needed?
  )
(add-hook 'erc-mode-hook #'erc-mode-hook-f)

;; keys - why is a call needed in the hook as well?
(defun set-erc-keys ()
  (let ((the-map erc-mode-map))
    (define-key the-map "\C-\M-p" #'erc-previous-command)
    (define-key the-map "\C-\M-n" #'erc-next-buffer)
    ; [...]
  ))
(set-erc-keys) ; not enough, apparently

> So If I understand right, if one untoggle the
> Wiki Link, then the link should disappeared,
> and WikiLink should not be underlined. And vica
> versa. Right?

I don't know because I just skimmed thru the
defun looking for simple style things to
spot/correct, I didn't think about what it was
supposed to do. I don't use wikis myself.
But if the key is up and running, debugging
will be much faster :) So what should the
function do, that it doesn't, or, what does it
do, that it shouldn't?

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




  reply	other threads:[~2017-08-17 11:42 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 [this message]
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

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=86tw16whck.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.