We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [string]

A string is a sequence of characters, which can be user data or used internally in Emacs. For example, string to search, replace, save in a register and so on, file name, etc.

Filter by
Sorted by
Tagged with
12
votes
4answers
1k views

Named string substitution?

I often have to make several substitution of the same string: (format "%s %s %s" "a" "a" "a") ;; gives: "a a a" (it's just a dummy example, in this case it's better to glue "a" with a whitespace, ...
9
votes
4answers
432 views

Which keyboard shortcut to use for navigating out of a string

When I'm in the middle of a looooong string, like the following (setq Emacs-beta "Which keyboard shortcut to use for navigating out of a string") Can I skip out of it, just before the first " (after ...
25
votes
2answers
5k views

How to check in elisp if a string is a substring of another string?

How to check if a string s1 is a substring of another string s2? For example (test-substring "f t" "df tj") --> t, (test-substring "ft" "df tj") --> nil.
6
votes
2answers
2k views

How can I turn a string into its literal representation?

(mystery-function "a neat\nstring\"") => "\"a neat \\nstring\\\"" This question was asked on freenode#emacs by user dropdrive. How could I write (or use) a function that takes a string literal ...
6
votes
3answers
97 views

Split a complicated string?

Q: how do I split a complicated string when whitespace delimiters aren't discriminating enough? Background I'm working with BibTeX files. I want to split an author string of the form "first-name ...
3
votes
1answer
166 views

modify syntax table for strings in perl modes

My company uses a version of Perl where you can define by binary number using something like my $var = 'b010110110; etc. Problem is both perl-mode and cperl-mode interpret ' as the start of the string ...
2
votes
1answer
344 views

prettify-symbols-mode and multi-character replacements?

With ``prettify-symbols-mode'' it is possible to replace strings by a character, or a character composition, e.g. ;; \lambda → λ (push '("\\lambda" . ?λ) prettify-symbols-alist) Optionally, it ...
12
votes
2answers
366 views

How do i get rid of “default” (last used) string in some emacs functions?

I have the following problem : when i use 'C-x r t' (string-rectangle), i am prompted to enter some string, to replace the selected rectangle. Lets say i type ";;" (to comment out the rectangle). This ...
2
votes
1answer
222 views

how to parameterize prompt for interactive/command?

background I had elisp code (in this very small git repo) like (defun bulk-replace-file (filepath) (interactive "FPath to file to bulk-replace: ") (bulk-replace-file-non-interactive filepath) ) ...
1
vote
1answer
74 views

Cperl-mode syntax highlighting breaks when inserting a newline into a here doc

in cperl-mode, here docs are colored with a font-lock-string-face. However if you used any function that inserts a newline on a blank line (e.g. M-: (insert "\n")) it will cause all code after the ...