ido-completing-read interaction with _ and -, hides possible results - emacs

When using ido-completing-read
(ido-completing-read "Which tag: " '("DALL-E" "monoidallens") nil t)
it finds both tags when I type "dall" but once I enter "dalle" it no longer finds "DALL-E"
Which tag: dall{DALL-E | monoidallens}
Which tag: dalle[monoidallens]
Whereas if I add an underscore to the "monoidal_lens" tag
(ido-completing-read "Which tag: " '("DALL-E" "monoidal_lens") nil t)
the input "dall" only matches "DALL-E" and while the input "dalle" matches both.
Which tag: dall[DALL-E]
Which tag: dalle{DALL-E | monoidal_lens}
Why does this happen? Is there a way to show all possible suggestions, adding more characters should not make suggestions go away.

Related

emacs-auctex refuses to open .tex-files

After installing emacs 28.1 and auctex 13.1 I can't open .tex-files any longer.
If I enter in emacs Ctrl-x -f Blau-2022-03-20.tex I get
Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
replace-regexp-in-string("\[ \\11\\15\\n%\]" "" nil)
LaTeX-xparse-macro-parse(mac)
LaTeX-xparse-auto-cleanup()
run-hooks(TeX-auto-cleanup-hook)
TeX-auto-parse()
run-hooks(TeX-update-style-hook)
TeX-update-style(t)
#f(compiled-function () #\<bytecode -0x12260f12797895d8\>)()
run-hooks(find-file-hook)
after-find-file(nil t)
find-file-noselect-1(#\<buffer Blau-2022-03-20.tex\> "\~/Desktop/Eigene Dokumente/Briefe/Blau- 2022-03-20...." nil nil "\~/Desktop/Eigene Dokumente/Briefe/Blau-2022-03-20...." (790801 2051))
find-file-noselect("\~/Desktop/Eigene Dokumente/Briefe/Blau-2022-03-20...." nil nil t)
find-file("\~/Desktop/Eigene Dokumente/Briefe/Blau-2022-03-20...." t)
funcall-interactively(find-file "\~/Desktop/Eigene Dokumente/Briefe/Blau-2022-03-20...." t)
call-interactively(find-file nil nil)
command-execute(find-file)
an can't open the file at all. If I click on the four dots, .tex appears.
BTW: It works with .tex~-files.
I have no idea what I could try, it worked for decades...
The question has been asked since 2014, but all solutions I found didn't work for me.
PS: It works if I enter myfile.tex for a second time. So after Ctr-x -f myfile.tex I get the strange message, but after another Ctr-x -f myfile.tex I can open the file as usual.

Org mode agenda: Reuse code in block agenda

I have an org-agenda-custom-commands like so:
("u" "Unscheduled TODO"
todo ""
((org-agenda-overriding-header "\nUnscheduled TODO")
(org-agenda-skip-function '(org-agenda-skip-entry-if
'scheduled 'deadline 'timestamp
'todo '("BACKBURNER")))))
I would like to reuse the todo part of this agenda view in other block agenda views. So for instance defining an unscheduled-todo list for reuse (pseudocode, not working):
(setq unscheduled-todo '((org-agenda-overriding-header "\nUnscheduled TODO")
(org-agenda-skip-function '(org-agenda-skip-entry-if
'scheduled 'deadline 'timestamp
'todo '("BACKBURNER")))))
(setq org-agenda-custom-commands
'(("u" "Unscheduled TODO"
(todo "" unscheduled-todo))
("c" "Complete View"
((agenda "")
(todo "" unscheduled-todo))))
How do I get the above code to work? I think I have a fundamental misunderstanding of how and when the code and lists are getting evaluated. I've tried a number of configurations of ' and () in both setq and org-agenda-custom-commands, along with append to create lists, but I'd also like to understand what's going on here.
Here's an implementation along the lines of my comment (although I think you really don't need a macro here: a function does just as well or better):
(defun unscheduled-todo ()
'((org-agenda-overriding-header "\nUnscheduled TODO")
(org-agenda-skip-function '(org-agenda-skip-entry-if
'scheduled 'deadline 'timestamp
'todo '("BACKBURNER")))))
(setq org-agenda-custom-commands
; N.B. the character following this comment is a *backquote*
; (the key to the left of the 1 key on a standard US keyboard);
; it is *NOT* a quote (the key to the left of the ENTER key
; on a standard US keyboard).
`(("u" "Unscheduled TODO"
todo "" ,(unscheduled-todo))
("c" "Complete View"
((agenda "")
(todo "" ,(unscheduled-todo))))))
I hope it's correct now (I had to fix it a couple of bugs) but it's only lightly tested.
Note that this uses the backquote mechanism to quote most of the value in the
setq of org-agenda-custom-commands while allowing the evaluation of the call to the macro using the comma mechanism.
EDIT: As #Rorschach points out in a (now deleted) comment, I'm overcomplicating things. You still need backquote and comma, but you can use the variable you defined:
(setq unscheduled-todo
'((org-agenda-overriding-header "\nUnscheduled TODO")
(org-agenda-skip-function '(org-agenda-skip-entry-if
'scheduled 'deadline 'timestamp
'todo '("BACKBURNER")))))
(setq org-agenda-custom-commands
; N.B. the character following this comment is a *backquote*
; (the key to the left of the 1 key on a standard US keyboard);
; it is *NOT* a quote (the key to the left of the ENTER key
; on a standard US keyboard).
`(("u" "Unscheduled TODO"
todo "" ,unscheduled-todo)
("c" "Complete View"
((agenda "")
(todo "" ,unscheduled-todo)))))
The backquote/comma mechanism allows the evaluation of a spliced-in variable just as well as it allows the evaluation of a spliced-in function call.

SystemVerilog $test$plusargs matches substring

We usually write testcases with VCS plusargs as follows
if($test$plusargs("Hello"))
do_hello_stimulus();
else if($test$plusargs("Hello1"))
do_hello1_stimulus();
But I found out $test$plusargs match even the substring. Even if we pass Hello1, it will call do_hello_stimulus(). Can anyone help me out how I should use to match exact string?
Thanks in advance
this is exactly the behavior defined in the standard. The $test$plusargs matches the prefix of an arg.
You can use the $value$plusargs instead to check the remainder of the string. Something like this:
if ($value$plusargs("hello%s", rest)) begin
if (rest == "")
$display("hello");
else
$display("hello: %s", rest);
end
else
$display("error");

Evaluating variables in Racket response/xexpr

I'm trying to make a simple bookmarking web-app in Racket.
It's meant to receive a url as a CGI argument, and right now, I'm just trying to confirm I received it by reflecting it back.
(define (start request)
(response/xexpr
(let* ([bindings (request-bindings request)]
[url (if (exists-binding? 'url bindings)
(extract-binding/single 'url bindings)
"NO URL")])
`(html
(head (title "TITLE"))
(body (h2 "TITLE")
(p "URL = " url))
))))
However, instead of seeing what I expect to see .. which is a page that contains
URL = http://google.com
I'm seeing
URL = &url;
Which suggests that url is being quoted literally in the xexpr (treated as an entity), rather than being evaluated as a variable.
So what am I doing wrong? How do I get url evaluated?
You need to use quasiquote and unquote to inject values into a quoted experession, more often seen as their reader abbreviation equivalents, ` and ,, respectively. When you use unquote/, inside of quasiquote/`, it will evaluate the expression and insert it into the surrounding quotation:
> (define url "http://google.com")
> `(p "URL = " ,url)
(p "URL = " "http://google.com")
You should put , in front of url in your template to unquote it.
For a more detailed explanation of quotation and quasiquotation, see Appendix A of this answer.
Use ,url :
`(html
(head (title "TITLE"))
(body (h2 "TITLE")
(p "URL = " ,url))
))))
Look for unquote in the documentation: http://docs.racket-lang.org/reference/quasiquote.html?q=unquote#%28form.%28%28quote.~23~25kernel%29._unquote%29%29

When creating a customizable value with defcustom, how can I validate users' entries?

I'm writing an elisp file that's evolving into a package, so I'm translating some of its variables into defcustom statements and documenting them. A few of these defcustom variables are related, and I'd like to validate values entered through the Customize system to ensure that the relationships hold true.
Here's an example of what I have:
(defcustom widget-canonical-names '("my_widget" . "widget_assembly 8911_j4")
"Documentation"
:type '(alist :key-type (string :tag "Widget's short name")
:value-type (string :tag "Full widget name"))
:risky nil
:group 'widgets)
(defcustom widget-colors '("my_widget" . "brown")
"Documentation"
:type '(alist :key-type (string :tag "Widget's short name")
:value-type (color :tag "color of the widget"))
:risky nil
:group 'widgets)
(defcustom widget-paths '("my_widget" . "~/widgets")
"Documentation"
:type '(alist :key-type (string :tag "Widget's short name")
:value-type (directory :tag "support files for widget"))
:risky nil
:group 'widgets)
So there are widgets and they have various settings, and I need to be able to access an arbitrary setting for a widget by knowing just the widget's short name. I'd like to make a validation function of some kind (googling around for "emacs defcustom validate" hasn't helped, unfortunately) such that if the user enters a widget name in widget-paths or widget-colors that is not in the widget-canonical-names list, they get an "are you sure?" warning and are cautioned about entering mismatched names. Can I attach such a validation function to my defcustoms? If so, what's the syntax for that?
Of course, what would be ideal would be to just make the user enter the short name once, but I can't figure out how to do that from the 'Composite Types' elisp documentation. So an even better answer to my question would tell me how to arrange a defcustom that sets up a data structure similar to this Python dict:
customized_widgets = {
"my_widget": { "canonical_name": "widget_assembly 8911_j4",
"widget_color": "brown",
"widget_path": "~/widgets",
},
"another_widget": { "canonical_name" : "widget_obsolete 11.0",
"widget_color": "blue",
"widget_path": "~/blue_widgets",
},
}
So: how can I get the behavior I want, where settings are grouped according to the data that'll be used to access them, or where a validation function warns users when they might be entering inconsistent data?
This will define the closest Emacs equivalent of that Python structure, with dicts represented as alists, and fixed keys of the inner dict represented as symbols.
(defcustom my-customized-widgets ()
"My widget customization alist"
:type '(alist
:tag "Widgets"
:key-type (string :tag "Short name")
:value-type
(set
:format "%v"
:entry-format "%b %v"
(cons :format "%v"
(const :format "" widget-canonical-name)
(string :tag "CName"))
(cons :format "%v"
(const :format "" widget-color)
(color :tag "Color"))
(cons :format "%v"
(const :format "" widget-path)
(directory :tag " Path"))))
:group 'widgets)