changelog shortlog graph tags branches changeset files file revisions raw help

Mercurial > core / annotate lisp/lib/organ/element/lesser/keyword.lisp

changeset 698: 96958d3eb5b0
parent: 609931bd65ba
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
133
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
1
 ;;; lib/organ/element/lesser/keyword.lisp --- Org Keyword Element
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
2
 
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
3
 ;; Keywords match the pattern '#+KEY: VALUE'
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
4
 
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
5
 ;; VALUE can be any of the standard-set of objects.
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
6
 
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
7
 ;; Affiliated keywords match the patterns:
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
8
 
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
9
 #|
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
10
 #+KEY: VALUE
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
11
 #+KEY[OPTVAL]: VALUE
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
12
 #+attr_BACKEND: VALUE
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
13
 |#
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
14
 
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
15
 ;;; Code:
128
99f2ab6bc8ba organ work
ellis <ellis@rwest.io>
parents:
diff changeset
16
 (in-package :organ)
133
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
17
 
287
609931bd65ba organ updates, readme.org
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
18
 (define-org-element keyword
609931bd65ba organ updates, readme.org
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
19
     ((key :accessor keyword-key :initarg :key :type string)
609931bd65ba organ updates, readme.org
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
20
      (val :accessor keyword-val :initarg :val))
609931bd65ba organ updates, readme.org
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
21
   :lesser t)
133
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
22
 
287
609931bd65ba organ updates, readme.org
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
23
 (define-org-parser (keyword :from string)
609931bd65ba organ updates, readme.org
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
24
   (multiple-value-bind (match-start match-end start end) (scan org-file-property-rx input)
609931bd65ba organ updates, readme.org
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
25
     (declare (ignore match-end))
609931bd65ba organ updates, readme.org
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
26
     (when match-start
609931bd65ba organ updates, readme.org
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
27
       (let ((key (subseq input (aref start 0) (aref end 0)))
609931bd65ba organ updates, readme.org
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
28
             (val (subseq input (aref start 1) (aref end 1))))
609931bd65ba organ updates, readme.org
Richard Westhaver <ellis@rwest.io>
parents: 136
diff changeset
29
         (org-create :keyword :key key :val val)))))
136
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
30
 
133
a5ae5a58c4cd org element comments and type definitions
ellis <ellis@rwest.io>
parents: 128
diff changeset
31
 (define-org-element affiliated-keyword (key opt value) :lesser t)
136
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
32
 
6ad95601645e org work, once we fix org-parse-planning-and-properties we ready to rumble
ellis <ellis@rwest.io>
parents: 133
diff changeset
33
 (define-org-parser (affiliated-keyword :from string))