Questions tagged [conditionals]
Questions about conditionals: cond, if, when, unless.
40 questions
0 votes
1 answer
71 views
Different outputs from minor-mode depending on major-mode
My minor-mode is inserting text in the current buffer. I want the default format of the text to be different depending on what major-mode the buffer is in, and to allow the user to override this ...
-1 votes
2 answers
72 views
Writing a conditional in a compact way
Could I write the if condition on the same line. Is there any other way to include the equivalent of the if conditional in a more compact way ? (pcase grapheme ("dinkus" (if (...
0 votes
2 answers
222 views
How to make optional parameters default to true?
In the question Optional parameter defaults, the suggested way to set default value for the parameter of an elisp function is along the lines of: (defun my-command (a &optional b) (command-...
-2 votes
1 answer
51 views
cond clause for optional arguments
Am using an optional argument and want to use cond to execute (do-this) if actm is present and matches 'regexp, and (do-that) otherwise. Is the following the correct way to do it, or am I missing ...
0 votes
1 answer
26 views
Resetting value when modulus computes to 0
Am doing the following computation where dmax is 8, whilst dcur start at 1 and increases bf increments of 1. I would like that when (mod dcur dmax) is 0, I use the value 8 rather than the value 0. (...
0 votes
2 answers
58 views
Avoiding code duplication with conditional code that uses let bindings
This is the procedural logic I want to program in Elisp: def my_func(): v1; v2; if (some_condition): v1 = 2 v2 = 3 else: v1 = 4 v2 = 5 foo(v1) ...
0 votes
1 answer
58 views
Emacs orgmode table formula to calculate different per km tariffs for trips under 100 km ans over 100km
I am new to Emacs Lisp. I have this price table in Org mode. A small portion of it is shown here: *** Destinations en France | Destination | Distance Km | Temps de trajet | Prix | |-...
3 votes
2 answers
349 views
Specify optional matches with pcase
Consider the following form: (pcase '(:def "k" #'foo :wk "ho") (`(:def ,(and (or (pred stringp) (pred vectorp)) key) ,(and (pred xl-sharp-quoted-symbol-p) def) :wk ...