changelog shortlog graph tags branches changeset files file revisions raw help

Mercurial > core / annotate lisp/lib/organ/util.lisp

changeset 698: 96958d3eb5b0
parent: 78ef6145e272
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
127
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents: 126
diff changeset
1
 ;;; lib/organ/util.lisp --- Organ Utils
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents: 126
diff changeset
2
 
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents: 126
diff changeset
3
 ;;
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents: 126
diff changeset
4
 
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents: 126
diff changeset
5
 ;;; Code:
129
80a56483f9b5 more organ work
ellis <ellis@rwest.io>
parents: 127
diff changeset
6
 (in-package :organ)
127
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents: 126
diff changeset
7
 
136
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 129
diff changeset
8
 (defun peek-line (stream)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 129
diff changeset
9
   (concatenate 
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 129
diff changeset
10
    'string 
263
b7183bfd7107 add doc/readme.txt, more doc upgrades
Richard Westhaver <ellis@rwest.io>
parents: 229
diff changeset
11
    (loop for c = (peek-char nil stream nil nil)
229
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
12
          until (or (not c) (char= c #\newline))
136
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 129
diff changeset
13
          collect c)))
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 129
diff changeset
14
 
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 129
diff changeset
15
 (defun read-until-end (stream)
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 129
diff changeset
16
   (with-output-to-string (s)
229
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
17
     (loop for c = (read-char stream nil)
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
18
           until (not c)
136
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 129
diff changeset
19
           do (write-char c s))))
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 129
diff changeset
20
 
127
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents: 126
diff changeset
21
 (defun read-org-lines (&optional stream)
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents: 126
diff changeset
22
   (apply #'vector
229
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
23
 	 (loop for l = (read-line stream nil)
7ca4cdbd52c2 bug fixes
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
24
 	       until (not l)
127
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents: 126
diff changeset
25
 	       collect l)))
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents: 126
diff changeset
26
 
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents: 126
diff changeset
27
 (defun read-org-lines-from-string (str)
960c010a23ce replaced lalr parser with YACC, removed vcard and ical data formats (requires xpath), added org elements and objects
ellis <ellis@rwest.io>
parents: 126
diff changeset
28
   (with-input-from-string (s str) (read-org-lines s)))
275
78ef6145e272 return of the uri
Richard Westhaver <ellis@rwest.io>
parents: 263
diff changeset
29
 
78ef6145e272 return of the uri
Richard Westhaver <ellis@rwest.io>
parents: 263
diff changeset
30
 ;; (sym-to-org-class-name 'headline)
78ef6145e272 return of the uri
Richard Westhaver <ellis@rwest.io>
parents: 263
diff changeset
31
 (eval-always
78ef6145e272 return of the uri
Richard Westhaver <ellis@rwest.io>
parents: 263
diff changeset
32
 (defun sym-to-org-class-name (sym) 
78ef6145e272 return of the uri
Richard Westhaver <ellis@rwest.io>
parents: 263
diff changeset
33
   "Convert keyword or symbol SYM to a symbol which could designate an ORG- object type."
78ef6145e272 return of the uri
Richard Westhaver <ellis@rwest.io>
parents: 263
diff changeset
34
   (intern (format nil "~:@(~a~a~)" "org-" sym) :organ)))