Hot answers tagged

7

Using the built-in cl-lib package, you can write the following: (eval-when-compile (require 'cl-lib)) (cl-decf (nth 1 x)) Alternatively, in vanilla Elisp: (setf (nth 1 x) (1- (nth 1 x))) Be careful, though, to avoid modifying quoted constant lists such as '(3 6) in-place, as doing so modifies the constant globally and may cause the code to behave ...


6

Linum mode provides the linum-format customizable variable that allows you to format how you want your line numbers to appear. Set this variable to have the value "%x" to get hexadecimal line numbers. This can be done either through the built-in customization process or by running (setq linum-format "%x"). Edit: You may only want to have ...


6

I did some searching and surprisingly couldn't find any existing minor modes that seemed to do this. I thought it would be a fun little project, however, so I've written a minimal minor mode (rainbow-numbers-mode) that does this and included it below. As it turns out, the only reasonable way to programmatically set text properties for something like this is ...


2

You can use org-number-to-letter from org-table.el (requires at least Emacs 26.1 or Org 9.1.9?) (require 'org-table) (org-number-to-letters 26) ;; => "Z" (org-number-to-letters 52) ;; => "AZ" And type C-M-% (query-replace-regexp) with [0-9]+ → \,(org-number-to-letters \#&) If you need to do the search-and-replace from Lisp, use re-search-...


2

104 would be cz I think. Using org mode eval setup:-- I suspect there are better choices fr functions but I'm an elisp learner. These conversions might be more appropriates in your code in that there's less if/thens based on ranges. #+begin_src emacs-lisp (setq c 104) (setq lsc (char-to-string (+ (% (- c 1) 26) (string-to-char "a")))) (setq msc (...


1

I have solved my problem using vectors. I have written two functions: convert-letter-to-digit: it takes a letter as argument and give a numnber as output; authors-letters-to-digits: call convert-letter-to-digit and replace letters with corresponding numbers. To write convert-letter-to-digit I was inspiered to vectors in C language, so I have defined a ...


1

Just tinkering, you can use car and cdr too. I'm sure someone will comment on whether this is good or bad. (let ((v 99) (p 3) (l (list 1 2 3 4))) (setcar (nthcdr p l) (+ (car (nthcdr p l)) v)) l) ;; => (1 2 3 103)


1

You can use this org table formula, format is used to ensure the number's width is 2 and padded with zero, as @sds's answer suggested: #+NAME: addition-table | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |---+----+----+----+----+----+----+----+----+----+----| | 0 | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | | 1 | 01 | 02 | 03 | 04 | 05 | 06 ...


1

TL;DR You need to format your numbers with the leading zeros if you want them: (format "%03d" 3) ==> "003" Details When you type (defvar foo '(00 01 02)) and evaluate it, Emacs reads the string "01" and recognizes it as a number (integer) and stores it in the list. Then it promptly forgets how the number was represented - as "1" or "01" or "000001". ...


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