From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: ~`symbol-function' to get code as list even when byte-compiled? Date: Wed, 27 May 2015 01:02:20 +0200 Organization: Aioe.org NNTP Server Message-ID: <87mw0rt01v.fsf@debian.uxu> References: <877frxid14.fsf@debian.uxu> <87twv18i91.fsf@kuiper.lan.informatimago.com> <87wpzw1t8e.fsf@debian.uxu> <87k2vw1rmh.fsf@debian.uxu> <87h9r0b40f.fsf@debian.uxu> <87382k19jm.fsf@debian.uxu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1432681220 30649 80.91.229.3 (26 May 2015 23:00:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 26 May 2015 23:00:20 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 27 01:00:19 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YxNpa-0002La-DA for geh-help-gnu-emacs@m.gmane.org; Wed, 27 May 2015 01:00:18 +0200 Original-Received: from localhost ([::1]:50596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxNpZ-0007u7-LB for geh-help-gnu-emacs@m.gmane.org; Tue, 26 May 2015 19:00:17 -0400 Original-Path: usenet.stanford.edu!goblin1!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 40 Original-NNTP-Posting-Host: feB02bRejf23rfBm51Mt7Q.user.speranza.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:MyN/agC1yR7M+JMlUTWUJpwHkx8= Mail-Copies-To: never Original-Xref: usenet.stanford.edu gnu.emacs.help:212311 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:104595 Archived-At: Stefan Monnier writes: >> Perhaps this is a better (safer) way to have it in >> but still out of action. > > Why have it out of action? The Right Thing to do is to > pass it along to fun: > > (defun add-one-shot-hook (hook fun) (let ((name > (cl-gensym))) (setf (symbol-function name) (lambda > (&rest args) (remove-hook hook name) (apply fun > args))) (add-hook hook name))) When I did this by putting the "payload" functions directly into the w3m hook that required them to all have one parameter, as w3m executed all them hook functions with the URL passed as (the single) argument. However now with this solution when there is a lambda around the functions the lambda can deal with the argument, so I removed the parameters from all the payloads. E.g., number-one-jump now looks like this: (defun number-one-jump () ; Google, Youtube (when (re-search-forward "^ 1." (point-max) t) (recenter-top-bottom 0) (w3m-next-anchor) )) So correct me if I'm wrong, but if I used `apply' with the argument as you suggest, wouldn't that lead to an error, namely wrong-number-of-arguments? On the other hand, if I then were to add those parameters again to the payloads, wouldn't I have the byte-compiler complain even more (once for each function) that *they* don't use the argument? -- underground experts united http://user.it.uu.se/~embe8573