From the docstring of C-x C-c:
With prefix ARG, silently save all file-visiting buffers, then kill.
So you want to use C-u C-x C-c
EDIT: If you also want that the above silently kills all running processes, then you can set the variable confirm-kill-processes to nil.
This is a representation of the character whose code is 367 in octal. This "general escape representation" is described in the elisp manual.
You can use the function text-char-description as:
M-: (text-char-description ?\367)
or M-x describe-char with point on the char
to see this is the character DIVISION SIGN.
Now the question is what does it stand ...
You can use cl-flet or cl-labels from cl-lib. The docstrings:
(cl-flet ((FUNC ARGLIST BODY...) ...) FORM...)
Probably introduced at or before Emacs version 24.3.
Make local function definitions.
Each definition can take the form (FUNC EXP) where
FUNC is the function name, and EXP is an expression that returns the
function value to which it should be ...
The short answer is no.
Once you declare a class, Emacs will define a function with the name of that class as a creation function, thereby replacing your old function definition. In Emacs, eieio.el has a macro for defclass that goes like so:
(defmacro defclass (name superclasses slots &rest options-and-doc)
;; A lot of stuff here...
This is because you modify the variable binding, not the data structure.
append creates a fresh list, while nconc modifies its argument.
Replace (setq perfect-numbers (append perfect-numbers new-perfect-numbers)) with (nconc perfect-numbers new-perfect-numbers) and you will get the behavior you think you want.
I must advise against this though because
(mapcar (lambda (entry) (+ entry 2)) x)
(mapcar (apply-partially #'+ 2) x)
And if you need to update x, then setq it to the result of one of the above forms, e.g.:
(setq x (mapcar (apply-partially #'+ 2) x))
You can use func-arity added in 26.1. C-h f func-arity:
func-arity is a built-in function in `C source code'.
Return minimum and maximum number of args allowed for FUNCTION.
FUNCTION must be a function of some kind.
The returned value is a cons
cell (MIN . MAX).
MIN is the minimum number of args.
MAX is the
(let ((name "foo")) (fset (intern name) (lambda (x) (* 2 x))))
(foo 21) ; 42
Brief explanation: (intern name) creates a symbol with the given name and adds it to the list of accessible symbols (that is what interning means). But if the symbol with that name already exists, it does nothing; just returns the already existing symbol.
And (lambda …) ...
All the modes you list are minor modes defined by define-minor-mode.
From the doc of define-minor-mode:
When called from Lisp, the mode command toggles the mode if the
argument is ‘toggle’, disables the mode if the argument is a
non-positive integer, and enables the mode otherwise (including
if the argument is omitted or nil or a positive integer).
Note: see Stefan's anwser.
It seems that local functions are not a native feature of the language. The GNU Reference Manual does not cover "local functions" or mention it.
(defun foo (a b)
(+ a b))
(setq val (symbol-value 'foo))
(symbol-function 'foo) returns (lambda (a b) (+ a b)) whereas (symbol-value 'foo) ...
I did C-h f C-h f and got a *Help* buffer describing
describe-function as a "Lisp function" defined in help-fns.el.
I clicked on the file name and searched for "Lisp function" which lead
me to the function help-fns-function-description-header whose code
indicated that what we want is subrp.
(subrp (symbol-function 'car))
A bit more consideration ...
If you've just typed or modified the function and you want to (re)define it, press C-M-x (eval-defun) with the cursor anywhere in the definition.
To run the function, use M-: (eval-expression) and type (count-words-buffer) then RET. If the function needed arguments, you'd need to add them after the function name, e.g. (my-function "first argument" 'second-...
Not exactly. Function buffer-substring requires two arguments. Function - will accept a single argument, but in that case it just returns the negative of that numeric argument. What you want to do is, in effect, apply such functions to a list of arguments. You can use higher-order function apply to do that.
What you can do, if you want, is have a macro or ...
You need to distinguish between
interactive command. The latter is also a function, but with the addition of (interactive) to its body.
You can run the latter, but not the former, by binding commands to
keys or calling them by name via M-x. See the elisp manual
links above more more details.
You are trying to use the values returned by functions outer-paren and sp-forward-sexp, instead of the positions they move to.
The error message tells you that narrow-to-region expects buffer positions - numbers or markers. So clearly your values of start and end aren't such. They aren't numbers or markers because functions outer-paren and sp-forward-sexp ...
Your C-h f is not the standard C-h f (M-x describe-function), describe-function doesn't provide "References ..." information at all. To find the source of apply, use C-h f apply, it will say
apply is a built-in function in `src/eval.c'.
src/eval.c will be clickable, then click it to go to the source. If you didn't install Emacs from the source code by ...
funcall takes a function as its first argument, so you need
if to return a function symbol. You can do that by
sharp-quoting its return value:
(defun a-plus-abs-b (a b)
(funcall (if (> b 0) #'+ #'-) a b))
(a-plus-abs-b 9 4) ; => 13
Elisp is a Lisp-2, which means each symbol can have a function
value and a variable value. When ...
At first the general statement: There is no buffer-local setting for the function cell of a symbol.
Now, I am just putting together the comments of lawlist and John Kitchin.
One can call an overriding function assigned to a buffer-local variable in an :around advice of helm-swoop-pre-input-optimize:
(defvar-local helm-swoop-pre-input-optimize-function nil
I ended up finding a suitable solution on another SO answer found here:
How to evaluate the variables before adding them to a list?
Return the argument, without evaluating it. (quote x) yields x.
Warning: quote does not construct its return value, but just returns
the value that was pre-constructed by the Lisp reader...
Hence, you ...
vc-git-grep is an interactive function which prompts, so when you want to call it from your own code you need to use call-interactively, otherwise it expects you to have supplied its required arguments in the call:
(setq vc-git-grep-template "git --no-pager grep -n -i -e <R> -- <F>")
I think I solved this with the following
;; [M-x my-quit] and [C-c q]
;; save all buffers then shuts down emacs stopping all current processes
(defun my-quit ()
(global-set-key (kbd "C-c q") 'my-quit)
I bind the function to C-c q which I don't use, but you can bind the ...
#' (= function) is more verbose than ' (= quote), and it provides three practical benefits.
1. Byte compiler will check if the function is defined
Byte compile a file which contains the following code
(mapc #'2+ nil)
(mapc '3+ nil)
The byte compiler will warns us that 2+ is not defined:
foo.el:3:1:Warning: the function `2+' is not known to be defined....
quote (') returns its argument sexp - any Lisp object (thing).
function (#') returns its argument sexp as a function object. This also means that in code you byte-compile it tells the byte compiler that that thing is a function.
'foobar just evaluates to the symbol foobar. #'foobar evaluates to a function.
'(lambda) () (something)) evaluates to the list ...
Posting answer to own question, including an example.
As @lawlist points out this can be done using defvar-local, this example uses macros to avoid writing boiler plate code and prints a message if the function isn't defined, runs a fallback function.
(defmacro my-generic-fn (var description)
(lambda () (interactive)
If a library developer is responsible for definining the mode dependent behavior and
you do not plan to allow the user to change it per defcustom you can use mode dependent overloads.
The code below is for playing around with mode local overrides. In buffers derived from text-mode [f9] prints "action in text-mode." in other buffers it prints "default ...