I have an Elisp function which takes a string and performs capitalization (capitalize
) on it, and then inserts it into a file. Apparently capitalize
doesn't consider the single quote as a "word constituent" and therefore I get results like "I'M A Cat".
I understand that this is because of the syntax table in place. The default returned by (standard-syntax-table)
treats the quote as a "word constituent", so I'm assuming that code execution uses emacs-lisp-mode-syntax-table
which has it otherwise.
I tried executing capitalize
inside with-temp-buffer
but that didn't work for some reason.
So my questions are:
- Does the functions I have in my config use
emacs-lisp-mode-syntax-table
when I call them? - What's the standard way of dealing with this? What's a way to isolate my functions from inheriting all this context? I don't want to manually create a new table and use
with-syntax-table
for every function in my config or change the current table usingmodify-syntax-entry
, and I want my strings to be treated like normal English sentences.
with-temp-buffer
hoping that the default table the buffer inherits would have apostrophe as a word constituent, but apparently that wasn't the case.... and then inserts it into a file
. How are you using it as a filename? Are you inserting it into the minibuffer in response to a prompt? The minibuffer has its own syntax tables:minibuffer-local-filename-syntax
andminibuffer-inactive-mode-syntax-table
. I presume the first one is then what matters.