1

I wonder why this keybind start not working, it used to work but not today.

;; defun my-exwm-launch
(defun my-new-exwm-launch (command)
  (lambda ()
    (interactive)
    (start-process-shell-command command nil command)))

(exwm-input-set-key (kbd "s-g") (my-new-exwm-launch "gkamus"))

I think I have this problem in the past too and I solved it by giving it lambda but that solution not work anymore

Update If I move the function and function to set keybind in elisp or .el file, it work

but If I use .org as dotfiles it not working I use this to load org file as dotfiles

(require 'org)
(org-babel-load-file (expand-file-name "~/.doom.d/personal/cheats_conf.org"   user-emacs-directory))
moanrisy
  • 100
  • 6
  • 1
    For starters, remove `(lambda ()` and also remove a closing parenthesis at the end of the function. Since you are formally defining a function with `defun`, you do not need `lambda` in this particular context. Note that a `lambda` can be used inside a function ..., but not in this particular context. – lawlist May 08 '20 at 06:31
  • After I remove `(lambda ()` and the closing parentheses of lambda the error changed to "Wrong type argument: commandp, # – moanrisy May 08 '20 at 06:49
  • 1
    Here is an example that works wherein I pass the ARG `-la` to the `ls` function, which is of course unrelated to your babel example: `(defun test-fn (arg) "Doc-string" (display-buffer (process-buffer (start-process "ls-process" "*OUTPUT-BUF*" "ls" arg)) t))` and `(global-set-key [f5] (lambda () (interactive) (test-fn "-la")))` .... – lawlist May 08 '20 at 07:11

1 Answers1

1

Try this instead:

(defun my-new-exwm-launch (command)
"Doc-string."
  (start-process-shell-command command nil command))

(exwm-input-set-key (kbd "s-g") (lambda () (interactive) (my-new-exwm-launch "gkamus")))

Based upon a comment from the O.P., here is a different example using a previous answer written by @sds at https://emacs.stackexchange.com/a/17421/2287 -- this example contains a general call to ls and passes the ARG of -la:

(defmacro defkey-arg (map key func &rest args)
  `(define-key ,map ,key (lambda () (interactive) (,func ,@args))))

(defun test-fn (arg)
"Doc-string"
  (display-buffer (process-buffer (start-process "ls-process"
                                                 "*OUTPUT-BUF*"
                                                 "ls"
                                                 arg))
                  t))

(defkey-arg global-map [f5] test-fn "-la")
lawlist
  • 18,826
  • 5
  • 37
  • 118
  • this working good :D, I can make exwm-input-set-key command shorter. I'm trying hard to make lambda and the interactive inside defun, but I guess, it's not possible. It's ok just by put start-process-shell-command inside defun. – moanrisy May 08 '20 at 07:21
  • I found an example by @sds wherein he creates a macro called `defkey-arg` ... and I updated the answer with a sample usage ... – lawlist May 08 '20 at 07:37