From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: Toggle WikiLink on and off does not work? Date: Thu, 17 Aug 2017 13:42:35 +0200 Message-ID: <86tw16whck.fsf@zoho.com> References: <86valnzhwa.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1502970271 14993 195.159.176.226 (17 Aug 2017 11:44:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 17 Aug 2017 11:44:31 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Aug 17 13:44:27 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1diJDs-0003Mk-I0 for geh-help-gnu-emacs@m.gmane.org; Thu, 17 Aug 2017 13:44:24 +0200 Original-Received: from localhost ([::1]:46926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diJDx-0002mP-E3 for geh-help-gnu-emacs@m.gmane.org; Thu, 17 Aug 2017 07:44:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diJCN-0002BK-GR for help-gnu-emacs@gnu.org; Thu, 17 Aug 2017 07:42:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diJCK-0001p9-C1 for help-gnu-emacs@gnu.org; Thu, 17 Aug 2017 07:42:51 -0400 Original-Received: from [195.159.176.226] (port=49554 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1diJCK-0001of-5c for help-gnu-emacs@gnu.org; Thu, 17 Aug 2017 07:42:48 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1diJCA-0006J4-8V for help-gnu-emacs@gnu.org; Thu, 17 Aug 2017 13:42:38 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 82 Original-X-Complaints-To: usenet@blaine.gmane.org Mail-Copies-To: never Cancel-Lock: sha1:hXVv9bngT0lI1uVkRZ+whwlcM0I= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:114066 Archived-At: 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