Re: tramp-aware bindings
On Thu, 15 Mar 2001, Tom Roche wrote: > Daniel Pittman <[EMAIL PROTECTED]> 16 Mar 2001 11:18:38 +1100 So, rather than doing (if ... 'tramp-compile 'compile), run the command you want, so: > (if ... (tramp-compile) (compile)) > > On Thu, 15 Mar 2001, Tom Roche wrote: >>> I get noise in *Messages* (broken for mail): > > Daniel Pittman <[EMAIL PROTECTED]> 16 Mar 2001 13:47:29 +1100 >> The noise is a byte-compiled version of the compile function. It >> takes a parameter, the event that started it. > >> So, you need to pass arg from your lambda to `compile'. :) Actually, no, you don't. I /am/ having a stupid day, I fear. [...] > *Backtrace* >> Signaling: (wrong-type-argument char-or-string-p nil) Quite. Because `compile' wants the command to run, not the event that caused it to be called. Try this for size, it /should/ work (with your key-binging, not mine :): (define-key global-map [(control f10)] (lambda (&rest args) (interactive) (if (tramp-file-p ...) (call-interactively 'tramp-compile) (call-interactively 'compile That should be a little more like what you want. Basically, that passes the call on to the correct version of the compile command (tramp or otherwise) as though they had been called from the keypress. I even tested it here and it did what I want, just like passing no arguments to the command. I hope this helps. I should think more, I guess, before suggesting solutions. :) Daniel -- Explain the concept of death very carefully to your child. This will make threatening him with it much more effective. -- P.J. O'Rourke
Re: tramp-aware bindings
Daniel Pittman <[EMAIL PROTECTED]> 16 Mar 2001 11:18:38 +1100 >>> So, rather than doing (if ... 'tramp-compile 'compile), run the >>> command you want, so: >>> (if ... (tramp-compile) (compile)) On Thu, 15 Mar 2001, Tom Roche wrote: >> I get noise in *Messages* (broken for mail): Daniel Pittman <[EMAIL PROTECTED]> 16 Mar 2001 13:47:29 +1100 > The noise is a byte-compiled version of the compile function. It > takes a parameter, the event that started it. > So, you need to pass arg from your lambda to `compile'. :) But it's optional. How to pass? If I do (define-key global-map "\M-`" (lambda (&optional arg) (interactive) (if (tramp-tramp-file-p buffer-file-name) (tramp-compile arg) (compile arg) ) ) ) with local file: *Backtrace* > Signaling: (wrong-type-argument char-or-string-p nil) > compile-internal(nil "No more errors") > compile(nil) > (if (tramp-tramp-file-p buffer-file-name) (tramp-compile arg) > (compile arg)) > (lambda (&optional arg) (interactive) (if (tramp-tramp-file-p > buffer-file-name) (tramp-compile arg) (compile arg)))() > call-interactively((lambda (&optional arg) (interactive) (if > (tramp-tramp-file-p buffer-file-name) (tramp-compile arg) (compile > arg (similar with tramped) Hey, no linenoise! But the signature of compile is (defun compile (command) and of compile-internal is (defun compile-internal (command error-message &optional name-of-mode parser error-regexp-alist name-function enter-regexp-alist leave-regexp-alist file-regexp-alist nomessage-regexp-alist) So how to get 'command to them? sorry to be so obtuse, but TIA, [EMAIL PROTECTED]
Re: tramp-aware bindings
On Thu, 15 Mar 2001, Tom Roche wrote: > Daniel Pittman <[EMAIL PROTECTED]> 16 Mar 2001 11:18:38 +1100 You want: > (define-key global-map "\M-`" (lambda (&optional arg) (interactive) (if (tramp-tramp-file-p buffer-file-name) 'tramp-compile 'compile ) ) ) > Umm ... I tried that. Is there a typo? > >> Probably. I didn't actually test it. :) > >> Hang on... It /looks/ right. Let me check my own sources. > >>> I can eval the above, checking to see that the key bound (it has). >>> But if I try to use the key, nothing happens. > >>> Ah. Wait. I see it. Let me guess, in the minibuffer, you see either >>> "compile" or "tramp-compile" when you hit the key, right? > > I see nothing. There's nothing in *Messages*, either. Oops, I take > that back: there's a suspicious Maybe. It's possible the command loop silently eats the symbol; it wouldn't surprise me. [...] >> You are returning a symbol from the keypress function which is then >> ignored. You actually need to /call/ the function you want run. > >> So, rather than doing (if ... 'tramp-compile 'compile), run the >> command you want, so: > >> (if ... (tramp-compile) (compile)) > > OK, I eval [...] > and I get noise in *Messages* (broken for mail): The noise is a byte-compiled version of the compile function. It takes a parameter, the event that started it. So, you need to pass arg from your lambda to `compile'. :) Daniel -- People of privilege will always risk their complete destruction rather than surrender any material part of their advantage. -- John Kenneth Galbraith, _The Age of Uncertainty_ (1977)
Re: tramp-aware bindings
Daniel Pittman <[EMAIL PROTECTED]> 16 Mar 2001 11:18:38 +1100 >>> You want: >>> (define-key global-map "\M-`" >>> (lambda (&optional arg) >>> (interactive) >>> (if (tramp-tramp-file-p buffer-file-name) >>> 'tramp-compile >>> 'compile >>> ) >>> ) >>> ) >>> Umm ... I tried that. Is there a typo? > Probably. I didn't actually test it. :) > Hang on... It /looks/ right. Let me check my own sources. >> I can eval the above, checking to see that the key bound (it has). >> But if I try to use the key, nothing happens. >> Ah. Wait. I see it. Let me guess, in the minibuffer, you see either >> "compile" or "tramp-compile" when you hit the key, right? I see nothing. There's nothing in *Messages*, either. Oops, I take that back: there's a suspicious Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %; q to quit; ? for help. and if I do it again, [2 times] gets appended. > You are returning a symbol from the keypress function which is then > ignored. You actually need to /call/ the function you want run. > So, rather than doing (if ... 'tramp-compile 'compile), run the > command you want, so: > (if ... (tramp-compile) (compile)) OK, I eval (define-key global-map "\M-`" (lambda (&optional arg) (interactive) (if (tramp-tramp-file-p buffer-file-name) (tramp-compile) (compile) ) ) ) and I get noise in *Messages* (broken for mail): > Wrong number of arguments: #[(command) "Ã > ?Ä\"ÅÆÇ!È\"É )ÊËÇ!\"ÅËÇ!!ÌÍ!" [command > compile-command compilation-ask-about-save save-some-buffers nil > pop-to-buffer get-buffer-create "*Compilation*" t erase-buffer] 4 > ("n:/site-lisp/tramp-2.9/lisp/tramp-util.elc" . 607) (byte-code > " So I delete tramp-util.elc (hoping to avoid bytecode), start another emacs with -debug-init, eval it again, and run it again: I get (broken for mail) *Backtrace* > Signaling: (wrong-number-of-arguments #[(command) "^H^QÃ ?Ä\"Å > Æ\"" [command compile-command compilation-ask-about-save > save-some-buffers nil compile-internal "No more errors"] 3 > ("n:/emacs-20.7/lisp/progmodes/compile.elc" . 13898) (byte-code > "^H^H > compile() > (if (tramp-tramp-file-p buffer-file-name) (tramp-compile) (compile)) > (lambda (&optional arg) (interactive) (if (tramp-tramp-file-p > buffer-file-name) (tramp-compile) (compile)))() > call-interactively((lambda (&optional arg) (interactive) (if > (tramp-tramp-file-p buffer-file-name) (tramp-compile) (compile Any suggestions? (Like, how to avoid the linenoise without deleting all my .elc's ?-) Your assistance is appreciated, [EMAIL PROTECTED]
Re: tramp-aware bindings
On Thu, 15 Mar 2001, Tom Roche wrote: > On Thu, 15 Mar 2001, Tom Roche wrote: > What am I doing wrong? [...] > Daniel Pittman <[EMAIL PROTECTED]> 16 Mar 2001 11:18:38 +1100 >> You want: > >> (define-key global-map "\M-`" >> (lambda (&optional arg) >> (interactive) >> (if (tramp-tramp-file-p buffer-file-name) >> 'tramp-compile >> 'compile >> ) >> ) >> ) > > Umm ... I tried that. Is there a typo? Probably. I didn't actually test it. :) Hang on... It /looks/ right. Let me check my own sources. > I can eval the above, checking to see that the key bound (it has). But > if I try to use the key, nothing happens. Ah. Wait. I see it. Let me guess, in the minibuffer, you see either "compile" or "tramp-compile" when you hit the key, right? You are returning a symbol from the keypress function which is then ignored. You actually need to /call/ the function you want run. So, rather than doing (if ... 'tramp-compile 'compile), run the command you want, so: (if ... (tramp-compile) (compile)) That'll teach me to answer questions without reading more than the top of the function. :) Daniel -- The heart has its reasons which reason knows nothing of. --Blaise Pascal, _Pensees_
Re: tramp-aware bindings
On Thu, 15 Mar 2001, Tom Roche wrote: What am I doing wrong? Daniel Pittman <[EMAIL PROTECTED]> 16 Mar 2001 10:48:11 +1100 >>> Add an `interactive' form to the top of the function. <[EMAIL PROTECTED]> Thu, 15 Mar 2001 19:06:25 -0500 >> Actually, I had tried that. If I do >> (define-key global-map "\M-`" >> (interactive) >> (lambda (&optional arg) >> (if (tramp-tramp-file-p buffer-file-name) >> 'tramp-compile >> 'compile >> ) >> ) >> ) >> I get >> Wrong number of arguments: #, 4 >> and if I do >> (define-key global-map "\M-`" >> (lambda (&optional arg) >> (interactive) >> (if (tramp-tramp-file-p buffer-file-name) >> 'tramp-compile >> 'compile >> ) >> ) >> ) >> I get nothing at all (including no error, even with debug-on-error >> t). Daniel Pittman <[EMAIL PROTECTED]> 16 Mar 2001 11:18:38 +1100 > You want: > (define-key global-map "\M-`" > (lambda (&optional arg) > (interactive) > (if (tramp-tramp-file-p buffer-file-name) > 'tramp-compile > 'compile > ) > ) > ) Umm ... I tried that. Is there a typo? I can eval the above, checking to see that the key bound (it has). But if I try to use the key, nothing happens. TIA, [EMAIL PROTECTED]
Re: tramp-aware bindings
On Thu, 15 Mar 2001, Tom Roche wrote: > On Thu, 15 Mar 2001, Tom Roche wrote: [...] > Daniel Pittman <[EMAIL PROTECTED]> 16 Mar 2001 10:48:11 +1100 >> Trying to bind a function that isn't interactive to a key sequence. >> Add an `interactive' form to the top of the function. > > Actually, I had tried that. If I do > >> (define-key global-map "\M-`" >> (interactive) >> (lambda (&optional arg) >> (if (tramp-tramp-file-p buffer-file-name) >> 'tramp-compile >> 'compile >> ) >> ) >> ) > > I get > >> Wrong number of arguments: #, 4 Ah. I see the problem. You want: (define-key global-map "\M-`" (lambda (&optional arg) (interactive) (if (tramp-tramp-file-p buffer-file-name) 'tramp-compile 'compile ) ) ) The `interactive' form belongs to the function - in this case, the function you construct on the fly with `lambda'. Daniel -- When I admire the wonder of a sunset or the beauty of the moon, my soul expands in worship of the Creator. -- Mohandas K. Gandhi
Re: tramp-aware bindings
On Thu, 15 Mar 2001, Tom Roche wrote: >> I've done several variations on >>> (define-key global-map "\M-`" >>> (lambda (&optional arg) >>> (if (tramp-tramp-file-p buffer-file-name) >>> 'tramp-compile >>> 'quote compile >>> ) >>> ) >>> ) >> none of which work: the current error is >>> Wrong type argument: commandp, (lambda (&optional arg) (if >>> (tramp-tramp-file-p buffer-file-name) (quote tramp-compile) >>> (quote compile))) >> What am I doing wrong? Daniel Pittman <[EMAIL PROTECTED]> 16 Mar 2001 10:48:11 +1100 > Trying to bind a function that isn't interactive to a key sequence. > Add an `interactive' form to the top of the function. Actually, I had tried that. If I do > (define-key global-map "\M-`" > (interactive) > (lambda (&optional arg) > (if (tramp-tramp-file-p buffer-file-name) > 'tramp-compile > 'compile > ) > ) > ) I get > Wrong number of arguments: #, 4 and if I do > (define-key global-map "\M-`" > (lambda (&optional arg) > (interactive) > (if (tramp-tramp-file-p buffer-file-name) > 'tramp-compile > 'compile > ) > ) > ) I get nothing at all (including no error, even with debug-on-error t). Your assistance is appreciated, [EMAIL PROTECTED]
Re: tramp-aware bindings
On Thu, 15 Mar 2001, Tom Roche wrote: [...] > Urgghh ... this highlights my elisp deficiency. I've done several > variations on > > ;; "Use 'tramp-compile' if in a tramp buffer, 'compile' otherwise." > (define-key global-map "\M-`" > (lambda (&optional arg) > (if (tramp-tramp-file-p buffer-file-name) > 'tramp-compile > 'quote compile > ) > ) > ) > > none of which work: the current error is > >> Wrong type argument: commandp, (lambda (&optional arg) (if >> (tramp-tramp-file-p buffer-file-name) (quote tramp-compile) >> (quote compile))) > > What am I doing wrong? Trying to bind a function that isn't interactive to a key sequence. Add an `interactive' form to the top of the function. Specifically, `(interactive)' should do what you want. Daniel -- We went too far, we can't turn back We built to high, we can't get down We are the slaves of our servants in the shadow of our ambitions -- Covenant, _Hardware Requiem_