Questions tagged [arguments]

"arguments" refer to those inputs to a function or program which are configurable by the caller, potentially differing on each call. Every argument is an input, but not every input is an argument -- for instance, a stream of data from a mouse could be an input and not an argument.

Filter by
Sorted by
Tagged with
0 votes
1 answer
24 views

pass arguments in call-process as key/value

I try to run a command which takes some arguments and requires to pass some attributes to the API. I understand that call-process takes args as strings but any invocation complains about wrong-type-...
b10n1k's user avatar
  • 101
0 votes
1 answer
77 views

Using ignore function with a more appropriate name

I want to use the function ignore but I want a more meaningful name when using its functionality of not doing anything. Would like to make a function that takes the same argument possibilities as ...
Dilna's user avatar
  • 1
0 votes
1 answer
29 views

Printing an alist to a specific buffer

I have the following code to print an alist. But I now want to recode this in a way that one can specify the buffer used for display. In addition, I would like that whether on not to erase the ...
Dilna's user avatar
  • 1
1 vote
1 answer
160 views

How do I pass an optional argument to a command called programmatically?

I would like to call a certain command from Emacs Lisp. This function takes two arguments plus a third optional argument. This third argument, when non-nil, doesn't ask for confirmation. I would like ...
Pablo's user avatar
  • 193
0 votes
1 answer
44 views

Fetch necessary function call arguments in Emacs

I started writing code in Emacs some days ago and i'm doing very well, however, a very difficult and boring situation is always annoying me, that is the moment of call a function written by me. To ...
Rômulo peres de moraes's user avatar
0 votes
1 answer
96 views

Changing value of a function argument

Have been playing with the following function (defun ignition (featr actm) "TODO." (when (eq 'sweep featr) (setq featr 'icomplt)) (message "%S" featr)) Calling the ...
Dilna's user avatar
  • 1
0 votes
1 answer
146 views

How to call a interactive function with prompt from a lambda?

I have this little LaTeX helper function: (defun my--insert-chord (chord) "Prompt for a CHORD and insert it at point. TODO: make it agnostic to the package used." (interactive "...
Alessandro Bertulli's user avatar
0 votes
2 answers
102 views

How to write a function that handles its argument [closed]

I would like to implement a sensible strategy for handling optional arguments. In this instance, I want the function to be as for a function like abbrev-mode (although not in the context of a minor ...
Dilna's user avatar
  • 1
0 votes
1 answer
22 views

Passing numeric value to a function

I have got the following function but want to pass a numeric mode even if completing-read asks for a string. (defun mycompany (mode) "Enables or disables company text completion in buffer."...
Dilna's user avatar
  • 1
0 votes
3 answers
52 views

Handling empty function optional argument [duplicate]

This function starts a new named shell buffer. How can I handle the case where bufrnm set by interactive in empty? (defun galaxy-shell (&optional bufrnm) "TODO" (interactive "...
Dilna's user avatar
  • 1
0 votes
1 answer
48 views

Handling optional arguments

This function makes a new named buffer that can run shell commands. But it only works properly when no argument is passed. When an argument is passed or set through the interactive clause, I would ...
Dilna's user avatar
  • 1
0 votes
2 answers
34 views

Checking optional function argument

If I have an optional function argument, how can I determine if name has been supplied. And if it has been supplied, how can I test its validity (not nil or not empty string). (defun myfunc (&...
Dilna's user avatar
  • 1
0 votes
1 answer
39 views

Set an empty string for function argument with list

I have a function argument and want to set an empty string for name and mode. What can I do? (defun bench (&optional name mode prefix) "DOCSTRING" (interactive (cond ((...
Dilna's user avatar
  • 1
0 votes
1 answer
34 views

Behaviour of Code Characters and Lists on Optional Arguments

Although the use of optional arguments to functions are easy to understand when running functions non-interactively. But things get complicated when declaring the function interactive, where you want ...
Dilna's user avatar
  • 1
1 vote
1 answer
1k views

Function arguments and interactive

I am having difficulty seeing how to properly use function arguments with the interactive command. Suppose I have a function with three arguments myfunc (arg1 &optional arg2 arg3), the last two ...
Dilna's user avatar
  • 1
-1 votes
1 answer
48 views

Changing of function arguments

I have a function workbench-named declared as follows, that calls another one called workbench. Have changed workbench to include a prefix argument. Thusly workbench-named is not calling workbench ...
Dilna's user avatar
  • 1
1 vote
1 answer
31 views

How to pass a variable to a click handler?

I'm using this code to make clickable text in a buffer: (defun q() "Entry point." (interactive) (let ((buffer-name "q")) (get-buffer-create buffer-name) (switch-to-...
gdonald's user avatar
  • 167
1 vote
1 answer
219 views

Interactive option for function with optional arguments

Am unsure whether making brcmk-end optional is possible for interactive use. If one can have optional arguments, what would be the changed necessary? Would the interactive expression change? (...
Dilna's user avatar
  • 1
1 vote
1 answer
44 views

Wrong type argument in conditional

I have the following code that counts the number of opening and closing braces, but getting the error and: Wrong type argument: stringp, 40 Here is the code: (defcustom rk-bracemk '("()"...
Dilna's user avatar
  • 1
1 vote
2 answers
354 views

Using defadvice to add an interactive argument to a non-interactive function?

Is there a way to wrap a non-interactive function within defadvice so that the new function can accept an interactive argument which can alter the way that the wrapped function gets called? In other ...
HippoMan's user avatar
  • 594
1 vote
1 answer
298 views

How can I apply function `max` to a list of numbers?

I want to find the max element in a list of numbers. (setq l (list 1 2 3 4 5)) What is an easy way to call the max function on l? So far I have this but this seems convoluted: (eval `(max ,@l)) It ...
jds's user avatar
  • 177
0 votes
0 answers
65 views

Cygwin ctrl-number not working (in cli emacs)

Originally posted to superuser. Cygwin ctrl-number is not working in cli emacs. I disabled the mintty options for keyboard shortcuts, so now ^- does work the same as ^u -1. Still, ctrl-number ...
memtha's user avatar
  • 137
1 vote
1 answer
234 views

Validating Arguments to a Function

I would like to validate the argument to a function before its action is executed. The main concern is the passing of a void variable. How can I trap this? (defun is-it-bound(item) (if (boundp 'item)...
naugiedoggie's user avatar
0 votes
1 answer
45 views

Passing variable to a function consisting of multiple components

Consider the following example: (defun glue (str1 str2) (format "%s%s" str1 str2)) (setq str1 "Hello, ") (setq str2 "World!") (insert (glue str1 str2)) This inserts ...
TimotaySci's user avatar
0 votes
1 answer
154 views

New `wrong-number-of-arguments` error from `desktop-change-dir` and other commands

(This has started happening with other commands too, but I don't remember which.) Previously when I ran M-x desktop-change-dir I would be prompted to enter a folder, whereupon Emacs would load the ....
Jeffrey Benjamin Brown's user avatar
0 votes
1 answer
66 views

How to use header-args variables to fill cell values of a table

I have an org-mode file as such: * Header level 1 :header-args: :var filename="somefile.csv" ** Header level 2 :header-args: :var foo="bar" #+begin_src emacs-lisp foo #+end_src #+...
Albert Vonpupp's user avatar
1 vote
3 answers
339 views

how to find number of arguments expected by an elisp function in emacs

I have some code that I use in my .emacs file that works with version 25.5 where the definition of windows--sanitize-window-sizes looks something like this: (defun window--sanitize-window-sizes (frame ...
intel_chris's user avatar
1 vote
0 answers
282 views

Defining a function that takes keyword arguments and a variable number of positional ones

I want to define a function that takes both keyword arguments (as in &key) and a variable number of positional ones (&rest). They should be independent of each other, the keyword list should ...
Nova's user avatar
  • 1,109
0 votes
2 answers
114 views

How to raise an error when unrecogized keyword arguments are passed to a function?

With a function that uses keyword arguments using this style of function definition: (defun some-name (&rest kwargs) (plist-get kwargs 'example)) Is there a convenient way to ensure only ...
ideasman42's user avatar
  • 8,726
1 vote
3 answers
656 views

Default argument when nil is provided

I'm writing a function which wraps org-export-as for use in html conversion of a file. In this function, I define the options for org-export-with-toc, org-export-with-section-numbers, and org-html-...
Lorem Ipsum's user avatar
  • 4,447
3 votes
1 answer
158 views

How to introspect function & macro arguments in elisp?

Is there a programmatic way to access function/macro arguments, Something like this, which returns the the arg count and true if it accepts any number of additional arguments. eg: (number-of-...
ideasman42's user avatar
  • 8,726
1 vote
1 answer
138 views

Use Elisp macro instead of two function arguments?

Is the following sort of shortcut macro possible to implement? (defmacro region-end-beg () "Replacement for '(region-end) (region-begin)' in source code" (...)) So that (buffer-substring (region-...
user26109's user avatar
1 vote
2 answers
137 views

Problem with giving inputs to a function programmatically

Some programs take user inputs, for example by calling the interactive function `sunrise-sunset', two arguments are taken from the user. Assume that the inputs are 0.0098 and 51.4934 (these are ...
Name's user avatar
  • 7,809
2 votes
1 answer
791 views

How to check whether an optional param was input?

I have a command with an optional argument whose value is a number. I need: If no input argument then use default value (1000) else use input arg. (random t) (defun insert-random-number-at-point(&...
a_subscriber's user avatar
  • 4,010
5 votes
2 answers
99 views

What is a good strategy to locating function arguments in a buffer?

I'd like to create a few routines for manipulating function arguments in buffers, which of course requires me to first locate the arguments. Suppose that I'm operating on a buffer with a programming ...
dpritch's user avatar
  • 445
1 vote
2 answers
105 views

advice-add FOR function dired-do-copy

I got a problem for an advice-add inside Dired's copy function (dired-do-copy). My object is it to filter all marked files/directories in Dired, which should be copied to an other location within ...
FalkH.'s user avatar
  • 11
2 votes
2 answers
298 views

Evaluating symbol in function arguments affected by destructive operations?

While evaluating a function call, the arguments is from left to right. For example, (let ((x '(1 2 3))) (list (nreverse x) x)) ;; => ((3 2 1) (1)) The first argument (nreverse x) evaluates to (...
xuchunyang's user avatar
  • 14.5k
2 votes
2 answers
111 views

Arbitrary length lists as argument for interactive function

Say I have a defun with a dolist inside that I want to be able to pass a string that is then converted to a list with a length equal to the number of words in said string via the minibuffer, so ...
Frede's user avatar
  • 55
1 vote
1 answer
250 views

Show constructor arguments for c++

Is there a package that can tell me the arguments for c++ constructor? class T1 { public: T1(int x, int y); }; T1::T1(int x, int y) { std::cout << x+y << std::endl; } ...
bon's user avatar
  • 13
2 votes
1 answer
357 views

Find out about arguments passed to functions

When I press C-h k C-SPC, Emacs shows me: C-SPC runs the command set-mark-command (found in global-map), which is an interactive compiled Lisp function. It is bound to C-@, C-SPC. (set-...
UTF-8's user avatar
  • 915
3 votes
1 answer
130 views

Was Emacs launched with a filename argument?

Suppose I want Emacs to be configured differently depending on whether or not it was launched with a filename as an argument. Is there a way I can deduce this as part of my init file? One way is to ...
Caterpillar's user avatar
2 votes
1 answer
1k views

Passing a symbol as an argument to a function

I'm trying to understand why this doesn't work, and how to make it work: (defvar test/var-1 nil) (defvar test/var-2 nil) (defun make-setter (var-to-set) (lambda (val-to-set) (setq var-to-set ...
Gastove's user avatar
  • 1,551
4 votes
3 answers
533 views

Reflection on function argument signatures

Is there anything built into elisp for reflection on function argument signatures? I have used (length (cadr (symbol-function #'my/function))), but this notably fails on built-in C functions. I'm ...
ebpa's user avatar
  • 7,439
4 votes
2 answers
207 views

Calling a function with a shorter but unknown argument signature length

Is there a terse idiomatic way of calling a function in the manner of funcall (dereferencing function symbols) when that function may have a variably shorter function signature? Say for example: a ...
ebpa's user avatar
  • 7,439
2 votes
2 answers
214 views

Can I pass an arbitrary symbol/keyword as a non-nil argument?

If a function takes a parameter whose only significance is in whether it's nil or non-nil, is there any reason not to pass it a well-named symbol to clarify what's going on in the calling code? For ...
ivan's user avatar
  • 1,938
7 votes
2 answers
164 views

Is there a way to only accept certain arguments to a function?

I want to write a function where the only two valid values for the input argument are "dag" or "rulegraph". Is there a way to specify that only these two arguments are accepted this in the elisp ...
The Unfun Cat's user avatar
1 vote
1 answer
304 views

How does (org-agenda-todo arg) work? What does the argument mean?

By trial and error I have found that in org-agenda (org-agenda-todo 'done) marks the entry at point as "DONE". Can you explain why? How can I modify the argument to the org-agenda-todo function (or ...
Alexander Shcheblikin's user avatar
0 votes
1 answer
111 views

How can I use a var to provide multiple arguments to a function? [duplicate]

Here is a simple example in which I would like to replace (start-process "ls" "*temp*" "ls" "-l" "-a" "-t" "-r") ; this works with (setq some-var ????) ; <-- Need to figure this part out (start-...
Kaushal Modi's user avatar
  • 25.6k
2 votes
2 answers
312 views

How to pass an argument from command to another command?

From the package Neotree, I want to bind a key, that moves to the upper directory. The upper directory is always on the top with .. (up a dir). So I go to the first line of the neotree buffer, and ...
ReneFroger's user avatar
  • 3,830
3 votes
2 answers
7k views

Error: Wrong type argument: symbolp, (t)

I'm new to emacs and try to learn elisp. I've read some tutorials and try to build now my own customized emacs. Looking at this blog I want to write a similar script for automatically installing ...
user8's user avatar
  • 171