10

I have run the following benchmarks on GNU Emacs 27.0.50 (build 14, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2018-02-21 without customisations, i.e. by starting Emacs with the -Q flag. Is there a more efficient alternative to search-forward when searching for a single character? [...] Does something like search-forward-char exist ...


9

You should be able to press C-\ (toggle-input-method) and give it german-postfix as an argument if asked (or with prefix) and then be able to type as you described. The minibuffer will show you hints how to enter the diacritics. As always you can ask Emacs to show the documentation for a key with C-h K.


9

From the documentation of insert-char, I cannot see why (insert-char "GREEK SMALL LETTER EPSILON") doesn't work. It doesn't work because insert-char understands Unicode character names only when called interactively (e.g. via C-x8RET or M-xinsert-charRET), as stated in its docstring: Interactively, prompt for CHARACTER. You can specify CHARACTER ...


8

Use Unicode char properties This should definitely work: (memq (get-char-code-property (char-after) 'general-category) '(Ll Lu Lo Lt Lm Mn Mc Me Nl)) As a bonus it should also be faster than looking-at. Emacs stores all character properties specified by the Unicode standard. They are accessible with get-char-code-property. Specifically, the general-...


7

edit: With Emacs 26.1 or later, it's a (setq display-raw-bytes-as-hex t) away. No, you can't. The display of unprintables above the printable ASCII range is hardcoded in xdisp.c: if (CHAR_BYTE8_P (c)) /* Display \200 instead of \17777600. */ c = CHAR_TO_BYTE8 (c); len = sprintf (str, "%03o", c + 0u); I sent a patch fixing this to debbugs.


7

From digging around in the source code for describe-char, get-char-code-property seems to be the right function: (get-char-code-property ?& 'name) "AMPERSAND"


7

EDIT: This answer should be perfectly valid in 25.5 (where the bug had been fixed). For older versions, use the other option. This should tell you if current char is a letter, and should work in any language. (looking-at-p "[[:alpha:]]")


6

Characters are numbers (non-negative integers under some limit), in Emacs. If you want to increment a single character, including a digit character, then just increment it as a character: (defun increment-char-at-point () "Increment number or character at point." (interactive) (condition-case nil (save-excursion (let ((chr (1+ (char-...


5

I figured it out thanks to the answer by Gilles and the 2010/2011 thread on gnu.emacs.help called “How switch from escaped octal character code to escaped HEX?” (Google Groups, Nabble). The details of how Emacs displays characters are in the section Display > Text Display (“How Text Is Displayed”) of the Emacs manual (C-h r), and section Display > Character ...


5

I found a solution. 1st run (print (font-family-list)) and get a full list of all fonts. Pick an installed Arabic font. In my case it was "clearlyu arabic". Add this line to the .emacs file: (when window-system (set-fontset-font "fontset-default" '(#x600 . #x6ff) "clearlyu arabic")) Change the font name at the end to the name of the font you have ...


5

I think you can get away with this: (defun test-letter () (interactive) (let ((char (char-after))) (if (and (eq (char-syntax char) ?w) (or (> char ?9) (< char ?1))) (message "This is a letter") (message "This is not a letter")))) Update This is a less efficient, but closer to what you want: (defun ...


4

Without switching input methods there is direct access to all the german extra characters via C-x 8 ". In particular C-x 8 " a gives ä C-x 8 " A gives Ä etc. and C-x 8 " s gives ß Similarly C-x 8 ' a gives á, C-x 8 ` a gives à, C-x 8 ^ a gives â and C-x 8 , c gives ç and other accents may be obtained in a comparable way. C-h b shows all current key ...


4

This is a Dead Keys problem, and it's mentioned in the Emacs wiki. All the workarounds explained there solve the issue.


4

Use char-after like so: (eq ?{ (char-after))


3

Emacs represents characters with the ?a syntax (or ?\X for special characters, where X is one of them). (characterp "a") ; => nil (characterp ?a) ; => t They evaluate to integers: (integerp ?a) ; => t They are not single-character strings, so the following will throw an ...


3

You can do it with display tables. This may be a little clumsy and I haven't investigated how this might interfere with packages that use display tables for their own purposes, but the basic use case works. (require 'cl-lib) (setq standard-display-table (make-display-table)) (cl-loop for x from 128 to 255 do (aset standard-display-table x (cl-map '...


3

You could have a look at key-seq or key-chord. Both lets you bind keys pressed together to a command, so if you press "ae" at the same time, you can bind it to "ä".


3

You can add a host of remappings of the form (define-key function-key-map [?\C-ь] [?\C-x]) See also https://stackoverflow.com/questions/10639429


3

There is a package for that -- reverse-im (https://github.com/a13/reverse-im.el) It does what you want with one exception -- it doesn't work for magit menus and other packages that uses a kind of non-default(?) approach for keybindings. PS I use it for cyrillic too.


3

[:ascii:] char class can help. C-M-% to query replace regexp \(\ *\)\([[:ascii:]]*[a-zA-z]\) with \1\\lr{\2} If new line character must not be included into sentence then change regexp to replace to \(\ *\)\([a-zA-z ]*[a-zA-z]\)


2

In case you were very concerned about national characters and precise treatment of Unicode character classes, then the only solution I was able to find so far is the Python regex library. Both grep and Perl (to my utter surprise!) didn't do the job properly. So, the regular expression you are after is this one: \p{L}. This is known as Unicode property ...


2

The accepted answer from @legoscia works only some of the time. It does not work for control characters, including code points between 0 and 32. They don't have a name in the Unicode database. But they do have an old-name. In Unicode, surrogate code points, private-use characters, control codes, noncharacters, and unassigned code points have no names. ...


2

This demonstration defines a highlighting color and commands which use anonymous faces to highlight a character or word. (defvar my-hl-color "#ff00ff") (defun my-hl-thing (boundaries) (put-text-property (car boundaries) (cdr boundaries) 'font-lock-face `(:background ,my-hl-color))) (defun my-hl-character () (interactive) (my-hl-...


2

It's not very clear what you are asking, IMO. There are various ways to highlight a particular character (e.g. everywhere in the region or in a buffer). Library highlight-chars.el provides one approach. Likewise, there are various ways to highlight a word (e.g. everywhere in the region or in a buffer). Library Highlight provides one approach. Ordinary ...


2

On old teletypewriters, the BS control character, written ^H, \008 or \b, would backspace the print head by one character position. Underlining could be achieved by overstriking a character with an underline (_^HH_^Hi), and bolding could be achieved by overstriking a character with itself (B^HBy^Hye^He). Teletypewriters no longer exist, but a number of ...


2

Testing whether some position is inside a comment or a string is hidden behind the obscurely named function syntax-ppss and its return value. I suppose the following will work. (defun python-compose-dashs (limit) (while (search-forward "-" limit t) (unless (or (nth 3 (syntax-ppss)) ;string (nth 4 (syntax-ppss))) ;comment (...


2

(defun char-below () (let ((col (current-column))) (save-excursion (if (not (zerop (forward-line 1))) nil (move-to-column col) (and (not (eolp)) (char-after)))))) But you don't say what you mean by "it breaks down in case the line below has tabs" or "accounting for the presence of tabs". If you want to consider that ...


2

Maybe something like this? I haven't tested it with tabs though... (defun char-below () (setq temporary-goal-column nil) (ignore-errors (save-excursion (next-line) (string (following-char))))) If you want it to return nil when there's no char below, because the row below is shorter than the current position, this is a modification: (...


2

Most likely your file is actually not using latin-1, yet your Emacs tries to decode it as if it were using latin-1. Try C-x RET r windows-1252 RET to see if it fixes your problem. If it does, you'll want to either add a -*- coding: windows-1252 -*- cookie on the first line of the file so Emacs knows how to decode it properly next time, or (the option I ...


2

You probably want the make-string function. If count starts at 0 and counts up, then: (make-string 1 (+ ?a count)) will go a, b, c, etc.


Only top voted, non community-wiki answers of a minimum length are eligible