aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2023-04-23 19:14:14 +0100
committerYann Herklotz <git@yannherklotz.com>2023-04-23 19:14:14 +0100
commit4d33a90680c3d187d5c79a88a597b57f20e67697 (patch)
treeebf038ddf1fac089d81549d592b34b7be8ab1f28
parente52a48214b6e266ddaee945bc2fd3ea8a9b1e8c7 (diff)
downloadyannherklotz.com-4d33a90680c3d187d5c79a88a597b57f20e67697.tar.gz
yannherklotz.com-4d33a90680c3d187d5c79a88a597b57f20e67697.zip
Fix 9 turning into colon
-rw-r--r--content.org23
1 files changed, 11 insertions, 12 deletions
diff --git a/content.org b/content.org
index 701732b..6b7aa29 100644
--- a/content.org
+++ b/content.org
@@ -475,20 +475,19 @@ ID, and one which will branch off of the current ID and create a parallel one.
first create a simple =ymhg/incr-id= function which simply increments the last character of the ID.
#+begin_src emacs-lisp
- (defun ymhg/incr-id (ident)
- (let* ((ident-list (append nil ident nil))
- (last-ident (last ident-list)))
- (setcar last-ident (+ (car last-ident) 1))
- (concat ident-list)))
+ (defun ymhg/incr-id (ident)
+ (let ((ident-list (string-to-list ident)))
+ (cl-incf (car (last ident-list)))
+ (concat ident-list)))
#+end_src
-However, one problem is that if we get to an ID with a =9= at the end, it will wrap around and
-generate a =0= at the end, followed by then generating an =:=, which will break the naming scheme. This
-could simply be fixed by turning the last value of the ID into a number, incrementing that, and
-turning it back into the original representation. However, for the current purposes we'll just
-assume that manual intervention will be required sometimes. Then, to create the function that
-generates an ID branching off of the current one, we just have to check if the current id ends with
-a number or a character, and add a =a= or =1= accordingly.
+However, one problem is that if we get to an ID with a =9=, it will stop incrementing correctly and
+turn into a =:=, which will break the naming scheme. This could simply be fixed by turning the last
+value of the ID into a number, incrementing that, then turning it back into the original
+representation. However, for the current purpose we'll just assume that manual intervention will be
+required sometimes. Then, to create the function that generates an ID branching off of the current
+one, we just have to check if the current id ends with a number or a character, and add a =a= or =1=
+accordingly.
#+begin_src emacs-lisp
(defun ymhg/branch-id (ident)