Why isn't this function working? reddit / emacs ---------------------------------------------------------------------- LowCom · 2022-05-12 06:04 (defun hidex() (menu-bar-mode 0) (tool-bar-mode 0) (scroll-bar-mode 0) ) ---------------------------------------------------------------------- s-kostyaev · 2022-05-12 06:18 Try -1 instead of 0 ---------------------------------------------------------------------- fraile_cucarro · 2022-05-12 06:59 Use nil ---------------------------------------------------------------------- hkjels · 2022-05-12 07:51 Use progn ---------------------------------------------------------------------- whudwl · 2022-05-12 08:16 `not working` meaning? ---------------------------------------------------------------------- 7890yuiop · 2022-05-12 08:19 It works fine (I just tested it), so you need to provide more information. Ignore everyone who doesn't understand minor mode arguments; yours are good/correct. ---------------------------------------------------------------------- LowCom · 2022-05-12 08:51 Oh Thanks, here is what I did. I wrote this in lisp-interactive-mode buffer, then did eval-buffer on the file but the menu changes didn't happen. That's what I meant by not working . ---------------------------------------------------------------------- LowCom · 2022-05-12 08:52 I wrote this in lisp-interactive-mode buffer, then did eval-buffer on the file but the menu changes didn't happen. That's what I meant by not working . ---------------------------------------------------------------------- whudwl · 2022-05-12 08:54 you have defined a function. now you need to call the function by writing `(hidex)`, place your cursor at the end of that, then `C-x C-e` ---------------------------------------------------------------------- LowCom · 2022-05-12 08:59 It works now , thank you. Dumb me. I was calling the funciton with hidex() as in python. I knew the lisp function syntax but python became a habit I guess. ---------------------------------------------------------------------- SlowValue · 2022-05-12 10:32 This would just wrap that `(prog1 ...)`, which is generated by the macro `defun`, with an additional `progn`. *Edit*: sorry above statement is wrong. Seems like I was confused by Common Lisps Hyperspec, which states "The body of the function defined by defun consists of forms; they are executed as an implicit progn when the function is called. This is unecessary. *Edit*: nevertheless an additional `progn` is unnecessary. ---------------------------------------------------------------------- hkjels · 2022-05-12 11:29 Wow. I’ve done a considerable amount of elisp, but did not know that. I more often than not have a let binding at the start of my functions though and I know that progn is not necessary then ---------------------------------------------------------------------- usaoc · 2022-05-12 12:15 [`defun` usually expands to a `defalias` with a `lambda`, unless there are declarations, in which case the `prog1` is around the `defalias` and declarations, not the body.](https://github.com/emacs- mirror/emacs/blob/aeefa3a732c9dd815e23ed10c4582082acb0e29b/lisp/emacs- lisp/byte-run.el#L351) ---------------------------------------------------------------------- SlowValue · 2022-05-12 13:16 Thanks for correcting me. ---------------------------------------------------------------------- 7890yuiop · 2022-05-12 20:06 It did work: it defined a function named `hidex`. That's what evaluating a `defun` form does. If you want to then *call* your function, you would use `(hidex)`. If you wanted to evaluate the code immediately, then you didn't want a function in the first place and hence didn't need to wrap the code in `(defun hidex () ...)` at all. ---------------------------------------------------------------------- oantolin · 2022-05-13 17:39 > Ignore everyone who doesn't understand minor mode arguments; yours are good/correct. Isn't using 0 undocumented? Here's what the docstring of a typical minor mode says: > If called from Lisp, toggle the mode if ARG is ‘toggle’. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number. It says what happens for positive numbers and what happens for negative numbers, but it doesn't say what happens for 0.