how to set 4 space indent in emacs - emacs

every time I add a new line, it would indent automatically but it indents 2 spaces, not 4 spaces.
Below is my .emacs snippet.
(defun make-vline-xpm (width height color &optional lor)
(let* ((w width)
(h height)
(s1 (concat "\"" (make-string w (string-to-char " ")) "\""))
(s2 (cond
((eq lor 0)
(concat "\"." (make-string (1- w) (string-to-char " ")) "\""))
((eq lor 1)
(concat "\"" (make-string (1- w) (string-to-char " ")) ".\""))
((null lor)
(concat "\"" (make-string (- (1- w)(/ (1- w) 2))(string-to-char " "))
"." (make-string (/ (1- w) 2)(string-to-char " ")) "\""))))
(sa (concat s1 ",\n" s2 ",\n")))
(eval `(concat "/* XPM */
static char * dot_vline_xpm[] = {
\"" (number-to-string w) " " (number-to-string h) " 2 1\",
\" c None\",
\". c " color "\",\n"
,#(mapcar (lambda(x) sa)
(make-list (1- (/ h 2)) 0))
s1 ",\n" s2 "};"
))))
(defvar indent-vline-img (make-vline-xpm 9 20 "#4D4D4D"))
(defun draw-indent-tab (beg end &optional color)
(if window-system
(set-text-properties
beg end
`(display (image
:type xpm
:data ,indent-vline-img
:pointer text
:ascent center
:mask (heuristic t))
rear-nonsticky (display)
fontified t))
(compose-region
beg end
(prog1 "|"
(set-text-properties beg end '(font-lock-face (:foreground "#4D4D4D"))))
'decompose-region)))
(defun draw-indent-vline ()
(interactive)
(save-excursion
(beginning-of-line)
(let* ((i (current-indentation))
(l (save-excursion
(count-lines (point)
(forward-list)))))
(while (> l 0)
(let* ((p1 (progn (move-to-column i)(point)))
(p2 (1+ p1)))
(if (and (eq (get-byte p1) 32)
(save-excursion
(skip-chars-backward " ")(bolp)))
(draw-indent-tab p1 p2))
nil)
(forward-line)
(setq l (1- l))))))
(defun indent-vline-lisp ()
(interactive)
(funcall
(lambda (x)
(font-lock-add-keywords
nil `((,x
(0 (draw-indent-vline))))))
"^[ \t]*[,`#'(]")
(defadvice delete-char (after indent-vline activate compile)
(save-excursion
(let* ((p (point))
(q (skip-chars-forward " "))
(x (progn (skip-chars-backward " ")(bolp))))
(if x
(remove-text-properties p (+ p q) '(display)))))))
(defun indent-vline ()
(interactive)
(funcall
(lambda (x)
(font-lock-add-keywords
nil `((,x
(0 (if (save-excursion
(skip-chars-backward " ")(bolp))
(let* ((p1 (point))
(p2 (1+ p1)))
(if (or (null (eq (get-byte p1) 32))
(get-text-property p1 'display))
nil
(draw-indent-tab p1 p2)
nil))))))))
" \\( \\)")
(defadvice delete-char (after indent-vline activate compile)
(save-excursion
(let* ((p (point))
(q (skip-chars-forward " "))
(x (progn (skip-chars-backward " ")(bolp))))
(if x
(remove-text-properties p (+ p q) '(display)))))))
I do not know lisp language. This .emscs is copied from others'. So my problem is how to set 4 space indent?
I have tried to add below to my .emacs, but it does not work.
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)

How about using custom-set-variables:
(custom-set-variables
'(tab-width 4))

Related

AutoLISP, How to export my selected polylines to a CSV with a name

I have this code below. It exports the selected polylines lenght to a CSV but it does not give it a name so i cant make a difference between two(or more) types of polyline.
My question is how to modify this code in order to be able to export the lenghts with the name of the linetype.
For example: I loaded ZIGZAG and TRACKS linetype, next I run my function and select all of the drawn polylines and I want to see in my CSV that which linetype is how long by name.
(defun c:Polyline_számoló (/ s i e l fn)
(if (and(setq s (ssget '((0 . "LWPOLYLINE"))))
(setq fn (getfiled "Create Output File" "" "csv" 1)))
(progn
(setq s (_SortSSByXValue s))
(setq i (sslength s))
(while (setq e(ssname s (setq i (1- i))))
(setq l (cons (vla-get-length (vlax-ename->vla-object e)) l))
(ssdel e s)
)
)
)
(setq l (list (cd:CON_All2Str l nil)))
(if (LM:WriteCSV l fn)
(startapp "explorer" fn)
)
(princ)
)
(defun cd:CON_All2Str (Lst Mode)
(mapcar
(function
(lambda (%)
(if Mode
(vl-prin1-to-string %)
(vl-princ-to-string %)
)
)
)
Lst
)
)
(defun _SortSSByXValue (ss / lst i e add)
(if (eq (type ss) 'PICKSET)
(progn
(repeat (setq i (sslength ss))
(setq lst (cons (cons (setq e (ssname ss (setq i (1- i))))
(cadr (assoc 10 (entget e)))
)
lst
)
)
)
(setq add (ssadd))
(foreach e (vl-sort lst (function (lambda (a b) (< (cdr a) (cdr b))))) (ssadd (car e) add))
(if (> (sslength add) 0)
add
)
)
)
)
(defun LM:writecsv ( lst csv / des sep )
(if (setq des (open csv "w"))
(progn
(setq sep (cond ((vl-registry-read "HKEY_CURRENT_USER\\Control Panel\\International" "sList")) (",")))
(foreach row lst (write-line (LM:lst->csv row sep) des))
(close des)
t
)
)
)
(defun LM:lst->csv ( lst sep )
(if (cdr lst)
(strcat (LM:csv-addquotes (car lst) sep) sep (LM:lst->csv (cdr lst) sep))
(LM:csv-addquotes (car lst) sep)
)
)
(defun LM:csv-addquotes ( str sep / pos )
(cond
( (wcmatch str (strcat "*[`" sep "\"]*"))
(setq pos 0)
(while (setq pos (vl-string-position 34 str pos))
(setq str (vl-string-subst "\"\"" "\"" str pos)
pos (+ pos 2)
)
)
(strcat "\"" str "\"")
)
( str )
)
)
Here's a lisp function that will export a csv file.
The csv file contains two sections:
1.) a length summary by linetype name
2.) an individual line summary with length and linetype
csv example:
--Length Summary By LineType--
LineType,Length
CENTER,739.97
HIDDEN,1858.61
--Length Breakdown By Individual Line--
LineType,Length
CENTER,246.656
HIDDEN,309.768
HIDDEN,309.768
CENTER,246.656
HIDDEN,309.768
HIDDEN,309.768
CENTER,246.656
HIDDEN,309.768
HIDDEN,309.768
Lisp code
;;www.cadwiki.net
(defun c:test (/ s i e l fn CSVSTRING CSVSTRINGLIST DATAITEM individualLineDataList LINELENGTH LINETYPE VLAOBJECT NEWASSOC NEWLENGTH PREVIOUSLENGTH lineTypeToLengthAssoc SUMMARYENTRY
)
(if (and (setq s (ssget '((0 . "LWPOLYLINE"))))
(setq fn (getfiled "Create Output File" "" "csv" 1))
)
(progn
(setq s (_SortSSByXValue s))
(setq i (sslength s))
(setq individualLineDataList (list))
(while (setq e (ssname s (setq i (1- i))))
(setq vlaObject (vlax-ename->vla-object e))
(setq lineType (vla-get-linetype vlaObject))
(setq lineLength (vla-get-length vlaObject))
(setq dataItem (list lineType lineLength))
(setq individualLineDataList (cons dataItem individualLineDataList))
(setq summaryEntry (assoc lineType lineTypeToLengthAssoc))
(if (/= summaryEntry nil)
(progn
(setq previousLength (cdr summaryEntry))
(setq newLength (+ previousLength lineLength))
(setq newAssoc (cons lineType newLength))
(setq lineTypeToLengthAssoc (REMOVE-ASSOC-BY-KEY lineType lineTypeToLengthAssoc))
(setq lineTypeToLengthAssoc (cons newAssoc lineTypeToLengthAssoc))
)
(progn
(setq newAssoc (cons lineType lineLength))
(setq lineTypeToLengthAssoc (cons newAssoc lineTypeToLengthAssoc))
)
)
(ssdel e s)
)
)
)
(setq csvStringList (list (list "--Length Summary By LineType--")))
(setq csvStringList (cons (list "LineType" "Length") csvStringList))
(foreach assocItem lineTypeToLengthAssoc
(setq csvString (summaryAssocToStringList assocItem))
(setq csvStringList (cons csvString csvStringList))
)
(setq csvStringList (cons (list "--Length Breakdown By Individual Line--") csvStringList))
(setq csvStringList (cons (list "LineType" "Length") csvStringList))
(foreach item individualLineDataList
(setq csvString (cd:CON_All2Str item nil))
(setq csvStringList (cons csvString csvStringList))
)
(setq csvStringList (reverse csvStringList))
(if (LM:WriteCSV csvStringList fn)
(startapp "explorer" fn)
)
(princ)
)
(defun REMOVE-ASSOC-BY-KEY (assocKey assocList / newAssocList item)
(setq newAssocList nil)
(foreach item assocList
(if (not (= (car item) assocKey))
(setq newAssocList (append newAssocList (list item)))
)
)
newAssocList
)
(defun summaryAssocToStringList (assocItem / LINELENGTH LINETYPE STRINGLIST)
(setq lineType (car assocItem))
(setq lineLength (cdr assocItem))
(setq stringList (list lineType (rtos lineLength 2 2)))
)
(defun cd:CON_All2Str (Lst Mode)
(mapcar
(function
(lambda (%)
(if Mode
(vl-prin1-to-string %)
(vl-princ-to-string %)
)
)
)
Lst
)
)
(defun _SortSSByXValue (ss / lst i e add)
(if (eq (type ss) 'PICKSET)
(progn
(repeat (setq i (sslength ss))
(setq lst (cons (cons (setq e (ssname ss (setq i (1- i))))
(cadr (assoc 10 (entget e)))
)
lst
)
)
)
(setq add (ssadd))
(foreach e (vl-sort lst (function (lambda (a b) (< (cdr a) (cdr b))))) (ssadd (car e) add))
(if (> (sslength add) 0)
add
)
)
)
)
(defun LM:writecsv (lst csv / des sep)
(if (setq des (open csv "w"))
(progn
(setq sep (cond ((vl-registry-read "HKEY_CURRENT_USER\\Control Panel\\International" "sList"))
(",")
)
)
(foreach row lst (write-line (LM:lst->csv row sep) des))
(close des)
t
)
)
)
(defun LM:lst->csv (lst sep)
(if (cdr lst)
(strcat (LM:csv-addquotes (car lst) sep) sep (LM:lst->csv (cdr lst) sep))
(LM:csv-addquotes (car lst) sep)
)
)
(defun LM:csv-addquotes (str sep / pos)
(cond
((wcmatch str (strcat "*[`" sep "\"]*"))
(setq pos 0)
(while (setq pos (vl-string-position 34 str pos))
(setq str (vl-string-subst "\"\"" "\"" str pos)
pos (+ pos 2)
)
)
(strcat "\"" str "\"")
)
(str)
)
)

Emacs -- How to extract all elements of a list

I am looking for some assistance, please, to extract all elements of a list of files and/or directories that have been marked in dired-mode. Essentially, if there were some way to just remove the parentheses from around the result of (mapcar (lambda (filename) (file-name-nondirectory filename)) (dired-get-marked-files)), then that would do the trick.
(start-process
"name-of-process"
"*output-buffer*"
"/usr/bin/zip"
"zip-file-name.zip"
(mapcar
(lambda (filename) (file-name-nondirectory filename))
(dired-get-marked-files)) )
The result I am seeking will look like this:
(start-process
"name-of-process"
"*output-buffer*"
"/usr/bin/zip"
"zip-file-name.zip"
"filename-number-one"
"filename-number-two"
"filename-number-three" )
EDIT:
The start-process function does not generally accept a single concatenated string of arguments. Instead, each argument must be separately spelled out (with quotation marks around each argument), or the argument can be a variable.
Here is the debugger message from the first example above -- the error occurs because there is a parentheses around the file names -- i.e., it cannot be a list.
Debugger entered--Lisp error: (wrong-type-argument stringp ("file-name-number-one" "file-name-number-two" "file-name-number-three"))
start-process("name-of-process" "*output-buffer*" "/usr/bin/zip" "zip-file-name.zip" ("file-name-number-one" "file-name-number-two" "file-name-number-three"))
eval((start-process "name-of-process" "*output-buffer*" "/usr/bin/zip" "zip-file-name.zip" (mapcar (lambda (filename) (file-name-nondirectory filename)) (dired-get-marked-files))) nil)
(cons (eval exp lexical-binding) values)
(setq values (cons (eval exp lexical-binding) values))
(let ((debug-on-error old-value)) (setq values (cons (eval exp lexical-binding) values)) (setq new-value debug-on-error))
(let ((old-value (make-symbol "t")) new-value) (let ((debug-on-error old-value)) (setq values (cons (eval exp lexical-binding) values)) (setq new-value debug-on-error)) (if (eq old-value new-value) nil (setq debug-on-error new-value)))
(if (null eval-expression-debug-on-error) (setq values (cons (eval exp lexical-binding) values)) (let ((old-value (make-symbol "t")) new-value) (let ((debug-on-error old-value)) (setq values (cons (eval exp lexical-binding) values)) (setq new-value debug-on-error)) (if (eq old-value new-value) nil (setq debug-on-error new-value))))
(let ((exp (if exp exp (read--expression "Eval: ")))) (if (null eval-expression-debug-on-error) (setq values (cons (eval exp lexical-binding) values)) (let ((old-value (make-symbol "t")) new-value) (let ((debug-on-error old-value)) (setq values (cons (eval exp lexical-binding) values)) (setq new-value debug-on-error)) (if (eq old-value new-value) nil (setq debug-on-error new-value)))) (let ((print-length (and (not (= 0 (prefix-numeric-value insert-value))) eval-expression-print-length)) (print-level (and (not (= 0 (prefix-numeric-value insert-value))) eval-expression-print-level)) (deactivate-mark)) (if insert-value (with-no-warnings (let ((standard-output (current-buffer))) (prog1 (prin1 (car values)) (if (= 0 ...) (progn ...))))) (prog1 (prin1 (car values) t) (let ((str (eval-expression-print-format ...))) (if str (princ str t)))))))
(if (active-minibuffer-window) nil (let ((exp (if exp exp (read--expression "Eval: ")))) (if (null eval-expression-debug-on-error) (setq values (cons (eval exp lexical-binding) values)) (let ((old-value (make-symbol "t")) new-value) (let ((debug-on-error old-value)) (setq values (cons (eval exp lexical-binding) values)) (setq new-value debug-on-error)) (if (eq old-value new-value) nil (setq debug-on-error new-value)))) (let ((print-length (and (not (= 0 ...)) eval-expression-print-length)) (print-level (and (not (= 0 ...)) eval-expression-print-level)) (deactivate-mark)) (if insert-value (with-no-warnings (let ((standard-output ...)) (prog1 (prin1 ...) (if ... ...)))) (prog1 (prin1 (car values) t) (let ((str ...)) (if str (princ str t))))))))
lawlist-eval-expression()
funcall-interactively(lawlist-eval-expression)
call-interactively(lawlist-eval-expression nil nil)
command-execute(lawlist-eval-expression)
What you want is to use apply with (mapcar ...) as its last argument:
(apply 'start-process
"name-of-process"
"*output-buffer*"
"/usr/bin/zip"
"zip-file-name.zip"
(mapcar #'file-name-nondirectory (dired-get-marked-files)))
Note that (mapcar #'function list) is a shorter spelling of (mapcar (lambda (arg) (function arg)) list).
combine-and-quote-strings is what you want:
(combine-and-quote-strings (mapcar (lambda (x)
(file-name-nondirectory x))
(dired-get-marked-files)))
EDIT: the following will give you a single, quoted string with internal quotes. Not sure if it'll play nicely with start-process:
(mapconcat
(lambda (x)
(concat "\"" (file-name-nondirectory x) "\""))
(dired-get-marked-files) " ")
EDIT: Righty-o, let's try this. Splice the backquoted list with ,#, then eval the whole thing:
(eval `(start-process
"name-of-process"
"*output-buffer*"
"/usr/bin/zip"
"zip-file-name.zip"
,#(mapcar
(lambda (x)
(file-name-nondirectory x))
(dired-get-marked-files))))

Common Lisp program error

Im pretty new in Lisp programming language and I got an error that I can't fix :/
Hope someone can help me. (Sorry if it's a newbie mistake)
Here's my code:
(defun inicia()
(princ "Ingresa la infija")
(setf temp(read-line))
(setf final nil)
(setf pilatemp nil)
(setf tamaño (length temp))
(setf cont 0)
(loop
(setf cadena (reverse temp))
(if (= cont tamaño) (return ))
(setf caracter (string (char temp cont)))
(if (= (operando caracter) 1) (push caracter final))
(if (= (operador caracter) 1) (PROGN (loop
(if (and (= cont tamaño) (<= (jerarquia caracter) (jerarquia (first pilatemp)))) (return))
(push (first pilatemp) final)
(pop pilatemp)
(setf cont (+ cont 1))))
(push caracter pilatemp)))
(if (equal caracter ")") (push caracter pilatemp))
(if (equal caracter "(") (PROGN (loop
(if (string= (first pila) ")") (return))
(push (pop pilatemp) final))
(pop pilatemp)))
(setf cont (+ cont 1)))
(loop
(setf tamaño (length pilatemp))
(if (<= tamaño 0) (return))
(if (equal (first pilatemp) ")") (pop pilatemp) (push (pop pilatemp) final))
(setf final (reverse final))))
(defun jerarquia(operan)
(cond
((string/= operan "^") 8)
((string/= operan "$") 8)
((string/= operan "*") 7)
((string/= operan "/") 6)
((string/= operan "+") 5)
((string/= operan "-") 4)
((string/= operan "(") 3)
((string/= operan ")") 2)
((string/= operan "=") 1)
(T 0)))
(defun operando (operan)
(cond
((= (operador operan) 0) 1)
;ojo con el retorno del siguiente if
((string/= operan "(") 1)
((string/= operan ")") 1)
(T 0)))
(defun operador (operan)
(cond
((string/= operan "+") 1)
((string/= operan "-") 1)
((string/= operan "*") 1)
((string/= operan "/") 1)
((string/= operan "^") 1)
((string/= operan "$") 1)
((string/= operan "=") 1)
(T 0)))
And the error I'm getting is the next one:
-SETQ: variable PILATEMP has no value
Thanks :)
You're getting this error because of one closing parenthesis too many:
(setf cont (+ cont 1)) ; <--- you had 3 closing parentheses here
(loop
(setf tamaño (length pilatemp))
(if (<= tamaño 0) (return))
(if (equal (first pilatemp) ")") (pop pilatemp) (push (pop pilatemp) final))
(setf final (reverse final))))
so the loop got executed at the top level, and not inside the function.

How to query syntax class constituents as string of char?

Using elisp I am trying to convert from an emacs syntax class \s_ to a string of characters that constitute this class using the syntax table. I have not been able to find some reference code or an example that I could identify.
Does anyone have a reference or a code snippet to share?
Thanks, Matt
Update 1 : After further reading, I have found that the table can be traversed with map-char-table, accumulating the required characters.
Some utilities in use here from
https://launchpad.net/s-x-emacs-werkstatt/
(defun ar-syntax-class-atpt (&optional pos)
"Return the syntax class part of the syntax at point. "
(interactive)
(let* ((pos (or pos (point)))
(erg (logand (car (syntax-after pos)) 65535)))
(when (interactive-p) (message "%s" erg)) erg))
(defun syntax-class-bfpt ()
"Return the syntax class part of the syntax at point. "
(interactive)
(let ((erg (logand (car (syntax-after (1- (point)))) 65535)))
(when (interactive-p) (message "%s" erg)) erg))
(defun ar-syntax-atpt (&optional docu pos)
(interactive)
(when pos
(goto-char pos))
(let* ((elt (car (if (featurep 'xemacs)
(char-syntax (char-after))
(syntax-after (point)))))
(stax (cond ((eq elt 0) "0 whitespace")
((eq elt 5) "5 close parenthesis")
((eq elt 10) "10 character quote")
((eq elt 1) "1 punctuation")
((eq elt 6) "6 expression prefix")
((eq elt 11) "11 comment-start")
((eq elt 2) "2 word")
((eq elt 7) "7 string quote")
((eq elt 12) "12 comment-end")
((eq elt 3) "3 symbol")
((eq elt 8) "8 paired delimiter")
((eq elt 13) "13 inherit")
((eq elt 4) "4 open parenthesis")
((eq elt 9) "9 escape")
((eq elt 14) "14 generic comment")
((eq elt 15) "15 generic string"))))
(when (interactive-p)
(message (format "%s" stax)))
(if docu
(format "%s" stax)
elt)))
(defun ar-syntax-in-region-atpt (beg end)
(interactive "r")
(save-excursion
(goto-char beg)
(let (erg)
(while (< (point) end)
(setq erg (concat erg "\n" "\"" (char-to-string (char-after)) "\"" " is " (ar-syntax-atpt t)))
(forward-char 1))
(message "%s" erg)
erg)))
(defun syntax-bfpt ()
(interactive)
(let ((stax (syntax-after (1- (point)))))
(when (interactive-p)
(message (format "%s" stax)))
stax))

Emacs determining keyboard layout

Is there a way for Emacs to detect the current keyboard layout?
I often write texts in English and German, switching the (Win OS) keyboard layout. However, some functions (C-Y e.g.) should always be at the same physical key, no matter what language Im currently typing in.
Thanks
Consider using M-x set-input-method and M-x toggle-input-method. Toggle is bound to C-\, set is bound to C-x RET C-\. I recommend this binding, if you have hyper key:
(global-set-key [?\H-\\] 'set-input-method).
If you asking not how to type in different language, but how to make several commands work when you using different languages in your OS, try just to bind them. It worked nice on russian symbols. One black-black night i even wrote
(setq russian-symbols '(
(?й . ?q)
(?ц . ?w)
(?у . ?e)
(?к . ?r)
(?е . ?t)
(?н . ?y)
(?г . ?u)
(?ш . ?i)
(?щ . ?o)
(?з . ?p)
(?х . ?\[)
(?ъ . ?\])
(?ф . ?a)
(?ы . ?s)
(?в . ?d)
(?а . ?f)
(?п . ?g)
(?р . ?h)
(?о . ?j)
(?л . ?k)
(?д . ?l)
(?ж . ?\;)
(?э . ?')
(?я . ?z)
(?ч . ?x)
(?с . ?c)
(?м . ?v)
(?и . ?b)
(?т . ?n)
(?ь . ?m)
(?б . ?,)
(?ю . ?.)
(?Й . ?Q)
(?Ц . ?W)
(?У . ?E)
(?К . ?R)
(?Е . ?T)
(?Н . ?Y)
(?Г . ?U)
(?Ш . ?I)
(?Щ . ?O)
(?З . ?P)
(?Х . ?{)
(?Ъ . ?})
(?Ф . ?A)
(?Ы . ?S)
(?В . ?D)
(?А . ?F)
(?П . ?G)
(?Р . ?H)
(?О . ?J)
(?Л . ?K)
(?Д . ?L)
(?Ж . ?:)
(?Э . ?\")
(?Я . ?Z)
(?Ч . ?X)
(?С . ?C)
(?М . ?V)
(?И . ?B)
(?Т . ?N)
(?Ь . ?M)
(?Б . ?<)
(?Ю . ?>)
(?Ё . ?~)
(?ё . ?`)
))
(setq russian-symbols-full (append russian-symbols
'((?. . ?/)
(?, . ??)
(?\" . ?#)
(?№ . ?#)
(?\; . ?$)
(?: . ?^)
(?\? . ?&))))
(defun cm-ru-to-en-string(string)
(apply 'concat (mapcar (lambda (arg) (setq arg (format "%c" (or (cdr (assoc arg russian-symbols-full)) arg)))) string)))
(defun cm-en-to-ru-string(string)
(apply 'concat (mapcar (lambda (arg) (setq arg (format "%c" (or (car (rassoc arg russian-symbols-full)) arg)))) string)))
(defun cm-ru-to-en-region()
(interactive)
(let ((text (buffer-substring-no-properties (mark) (point))))
(delete-region (mark) (point))
(insert (cm-ru-to-en-string text))))
(defun cm-en-to-tu-region()
(interactive)
(let ((text (buffer-substring-no-properties (mark) (point))))
(delete-region (mark) (point))
(insert (cm-en-to-ru-string text))))
;; DO NOT USE vvv SINCE YOU WILL NOT BE ABLE TO INPUT THROUGH C-\
;; (let ((symbols russian-symbols))
;; (while symbols
;; (global-set-key (vector (car (car symbols))) (vector (cdr (car symbols))))
;; (setq symbols (cdr symbols))))
;; DO NOT USE ^^^ SINCE YOU WILL NOT BE ABLE TO INPUT THROUGH C-\
;; (- ?\C-ы ?ы) ;;russian C-
;; (- ?\C-s ?s) ;;english C-
;; (- ?\M-ы ?ы) ;;russian M-
;; (- ?\M-s ?s) ;;english M-
(setq russian-symbols-map1
(append
(mapcar (lambda (arg) (setq arg (cons (+ (- ?\C-ы ?ы) (car arg)) (+ (- ?\C-s ?s) (cdr arg))))) russian-symbols)
(mapcar (lambda (arg) (setq arg (cons (+ (- ?\M-ы ?ы) (car arg)) (+ (- ?\M-s ?s) (cdr arg))))) russian-symbols)
(mapcar (lambda (arg) (setq arg (cons (+ (- ?\C-\M-ы ?ы) (car arg)) (+ (- ?\C-\M-s ?s) (cdr arg))))) russian-symbols)
(mapcar (lambda (arg) (setq arg (cons (+ (- ?\H-ы ?ы) (car arg)) (+ (- ?\H-s ?s) (cdr arg))))) russian-symbols)
(mapcar (lambda (arg) (setq arg (cons (+ (- ?\H-\C-ы ?ы) (car arg)) (+ (- ?\H-\C-s ?s) (cdr arg))))) russian-symbols)
(mapcar (lambda (arg) (setq arg (cons (+ (- ?\H-\M-ы ?ы) (car arg)) (+ (- ?\H-\M-s ?s) (cdr arg))))) russian-symbols)
(mapcar (lambda (arg) (setq arg (cons (+ (- ?\H-\C-\M-ы ?ы) (car arg)) (+ (- ?\H-\C-\M-s ?s) (cdr arg))))) russian-symbols)))
(setq russian-symbols-map2
(append
russian-symbols-map1
russian-symbols)) ; We must not start with russian letters, but if it is element in a sequence - in should be fine.
(setq symbols2 russian-symbols-map1) ; One-key sequence command.
(let ((symbols2 russian-symbols-map1))
(while symbols2
(if
(and (symbolp (lookup-key global-map
(vector
(cdr (car symbols2))
)))
(lookup-key global-map
(vector
(cdr (car symbols2))
)))
(global-set-key
(vector
(car (car symbols2))
)
(lookup-key global-map
(vector
(cdr (car symbols2))
))))
(setq symbols2 (cdr symbols2))))
(let ((symbols1 russian-symbols-map2) (symbols2 russian-symbols-map1)) ; Two keys sequence
(while symbols1
(while symbols2
(if
(and (symbolp (lookup-key global-map
(vector
(cdr (car symbols2))
(cdr (car symbols1))
)))
(lookup-key global-map
(vector
(cdr (car symbols2))
(cdr (car symbols1))
)))
(global-set-key
(vector
(car (car symbols2))
(car (car symbols1))
)
(lookup-key global-map
(vector
(cdr (car symbols2))
(cdr (car symbols1))
))))
(setq symbols2 (cdr symbols2)))
(setq symbols2 russian-symbols-map1)
(setq symbols1 (cdr symbols1))))
(provide 'shamanizm) ;russian emacs-users should lol reading this
It works. I've binded all global hotkeys up to 2 level with russian symbols.
I am not using it now, it eat startup time, and it ruins readability of my *Help* with crazy things like It is bound to C-x b, C-x и, C-ч b, C-ч и. Use it wisely.