summaryrefslogtreecommitdiff
path: root/tissue/person.scm
diff options
context:
space:
mode:
authorArun Isaac2022-07-09 11:08:20 +0530
committerArun Isaac2022-07-09 16:41:01 +0530
commit2f5578be4545af1dd530bfc7a1ef235620ba9519 (patch)
tree1bcfd29d243320a95c544187351c38b82f9bf01b /tissue/person.scm
parenta132df19eabf5d77b0eac7e870178803f1b0dd07 (diff)
downloadtissue-2f5578be4545af1dd530bfc7a1ef235620ba9519.tar.gz
tissue-2f5578be4545af1dd530bfc7a1ef235620ba9519.tar.lz
tissue-2f5578be4545af1dd530bfc7a1ef235620ba9519.zip
issue: Move person related functions to (tissue person).
* bin/tissue: Import (tissue person). * tissue/issue.scm: Import (tissue person). (%aliases, resolve-alias, index-person!): Move to (tissue person). * tissue/person.scm: New file.
Diffstat (limited to 'tissue/person.scm')
-rw-r--r--tissue/person.scm48
1 files changed, 48 insertions, 0 deletions
diff --git a/tissue/person.scm b/tissue/person.scm
new file mode 100644
index 0000000..e1c0ae1
--- /dev/null
+++ b/tissue/person.scm
@@ -0,0 +1,48 @@
+;;; tissue --- Text based issue tracker
+;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; This file is part of tissue.
+;;;
+;;; tissue is free software: you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation, either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; tissue is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with tissue. If not, see <https://www.gnu.org/licenses/>.
+
+(define-module (tissue person)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26)
+ #:use-module (ice-9 match)
+ #:use-module (xapian xapian)
+ #:export (%aliases
+ resolve-alias
+ index-person!))
+
+(define %aliases
+ (make-parameter #f))
+
+(define (resolve-alias name aliases)
+ "Resolve NAME against ALIASES, a list of aliases. ALIASES should be
+in the form of the argument of the same name to `tissue-configuration'
+in (tissue tissue). If no alias is found, NAME is returned as such."
+ (cond
+ ((find (cut member name <>)
+ aliases)
+ => (match-lambda
+ ((canonical-name _ ...) canonical-name)
+ (() name)))
+ (else name)))
+
+(define (index-person! term-generator name prefix)
+ "Index all aliases of person of canonical NAME using TERM-GENERATOR
+with PREFIX."
+ (for-each (cut index-text! term-generator <> #:prefix prefix)
+ (or (assoc name (%aliases))
+ (list))))