From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Jeff Rancier" Newsgroups: gmane.emacs.help Subject: Re: Adding to ps-print-hook problems Date: Mon, 16 Sep 2002 17:29:04 GMT Organization: Road Runner Sender: help-gnu-emacs-admin@gnu.org Message-ID: References: <3D8608CE.9000802@ihs.com> NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1032197777 3997 127.0.0.1 (16 Sep 2002 17:36:17 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 16 Sep 2002 17:36:17 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17qznD-000126-00 for ; Mon, 16 Sep 2002 19:36:15 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17qznP-0007o5-00; Mon, 16 Sep 2002 13:36:27 -0400 Original-Path: shelby.stanford.edu!nntp.stanford.edu!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!cpk-news-hub1.bbnplanet.com!news.gtei.net!newsfeed1.cidera.com!Cidera!cyclone.nyroc.rr.com!cyclone-out.nyroc.rr.com!twister.nyroc.rr.com.POSTED!not-for-mail Original-Newsgroups: comp.emacs,gnu.emacs.help Original-Lines: 65 X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Original-NNTP-Posting-Host: 24.97.108.46 Original-X-Complaints-To: abuse@rr.com Original-X-Trace: twister.nyroc.rr.com 1032197344 24.97.108.46 (Mon, 16 Sep 2002 13:29:04 EDT) Original-NNTP-Posting-Date: Mon, 16 Sep 2002 13:29:04 EDT Original-Xref: nntp.stanford.edu comp.emacs:74537 gnu.emacs.help:104949 Original-To: help-gnu-emacs@gnu.org Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:1504 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:1504 I changed it as follows: (defun jbr-ps-print-n-up-hook (&optional number-of-pages) adding the ampersand. Now, if I call ps-print-buffer-with-faces() non-interactively, it works as before, which is good. If I call ps-print-buffer-with-faces() interactively, (with C-2, for example, I'm assumed that the 2 will be passed interactively to my hook function), the interactive call, is only for the immediate function which gets called, i.e., ps-print-buffer-with-faces(), which I guess makes good sense. I then get prompted for a post-script filename to the buffer to be spooled to. So, I guess the next question is: How do I bypass the interactive property of ps-print-buffer-with-faces(), and have my hook function be interactive? "Kevin Rodgers" wrote in message news:3D8608CE.9000802@ihs.com... > Jeff Rancier wrote: > > > Hi all. I wanted to create a simple function to prompt me for the n-up > > number of pages to print when I run the function, > > ps-print-buffer-with-faces. Here's what I came up with: > > > > (defun jbr-ps-print-n-up-hook (number-of-pages) > > (interactive "nN-up number of pages: ") > > (setq ps-n-up-printing number-of-pages)) > > > > (add-hook 'ps-print-hook 'jbr-ps-print-n-up-hook) > > > > I thought that was pretty straight forward. When I select that from the > > menu-bar, I get the following in my *Messages* buffer: > > > > Debugger entered--Lisp error: (wrong-number-of-arguments (lambda > > (number-of-pages) (interactive "nN-up number of pages: ") (setq > > ps-n-up-printing number-of-pages)) 0) > > jbr-ps-print-n-up-hook() > > run-hooks(ps-print-hook) > > ps-spool-with-faces(1 2947 nil) > > ps-print-with-faces(1 2947 nil) > > ps-print-buffer-with-faces(nil) > > * call-interactively(ps-print-buffer-with-faces) > > > > Is that the wrong-number-of-arguments to run-hooks? And if so, is that a > > bug in ps-print? Or am I incorrectly writing my hook, > > jbr-ps-print-n-up-hook? I am simply calling ps-print-buffer-with-faces() > > incorrectly, now that it is interactive? > > > Hook functions are always called with no arguments, but your function requires > > one argument. Just make it optional: > > (defun jbr-ps-print-n-up-hook (optional number-of-pages) > ...) > > -- > Kevin Rodgers >