1
0
Fork 0

Compare commits

...

2 Commits

Author SHA1 Message Date
cage 5201953a08 - [gemini] fixed parsing of quoted lines, an empty line can be part of the quote. 2021-05-09 17:01:51 +02:00
cage 5f8c20ce7d - wrapped sb-ext:run-program;
- do not load configuration files if cli options '-h' or '-v' are used.
2021-05-09 16:32:32 +02:00
4 changed files with 61 additions and 38 deletions

View File

@ -119,7 +119,7 @@ color-regexp = "➶ .+" magenta bold
# header level 1
color-regexp = "🞂 .+" white bold
color-regexp = "^🞂.*" white bold
# header level 2

View File

@ -165,10 +165,12 @@
(list (coerce (second a) 'string))))))
(defrule quote-line (and quote-prefix
text-line)
(? text-line))
(:function (lambda (a) (list (first a)
nil
(tag-value (second a))))))
(if (second a)
(tag-value (second a))
"")))))
(defrule gemini-file (* (or h3
h2
@ -467,11 +469,15 @@
(format nil "~a~a~%" (link-prefix-gemini theme) link-name)
(format nil "~a~a~%" (link-prefix-other theme) link-name)))
(fit-quote-lines (line win-width)
(let* ((justified (flush-left-mono-text (split-words line)
(let* ((words (split-words line))
(quote-prefix (quote-prefix theme))
(justified (flush-left-mono-text words
(- win-width
(length (quote-prefix theme)))))
(lines (mapcar (lambda (a) (strcat (quote-prefix theme) a))
justified)))
(length quote-prefix))))
(lines (if justified
(mapcar (lambda (a) (strcat quote-prefix a))
justified)
quote-prefix)))
(make-quoted-lines (join-with-strings lines (format nil "~%")))))
(pre-alt-text (node)
(trim (html-utils:attribute-value (html-utils:find-attribute :alt node))))

View File

@ -114,11 +114,13 @@ etc.) happened"
(invoke-restart 'res:create-empty-in-home))))
(swconf:load-config-file swconf:+conf-filename+)))
(defun shared-init ()
(load-configuration-files)
(init-db))
(defun init ()
"Initialize the program"
;; (res:init)
;; (load-configuration-files)
;; (init-db)
(shared-init)
(db-utils:with-ready-database (:connect nil)
(complete:initialize-complete-username-cache)
(handler-case
@ -182,7 +184,7 @@ etc.) happened"
(defun load-script-file ()
"Load (execute) a lisp file used in requests of a command line switch"
(setf program-events:*process-events-immediately* t)
(init-db)
(shared-init)
(db-utils:with-ready-database (:connect nil)
(client:init)
(client:authorize)
@ -192,8 +194,6 @@ etc.) happened"
"The entry point function of the program"
(init-i18n)
(res:init)
(load-configuration-files)
(init-db)
(command-line:manage-opts)
(if command-line:*script-file*
(load-script-file)

View File

@ -73,13 +73,30 @@
(values exe args))
(values editor nil))))))
(defun run-external-program (program args
&key
(wait t)
search
#-win32 pty
input
output
(error :output))
(sb-ext:run-program program
args
:wait wait
:search search
:pty pty
:input input
:output output
:error error))
(defun open-with-editor (file)
(multiple-value-bind (exe args)
(external-editor)
(let ((actual-args (if args
(text-utils:split-words args)
nil)))
(sb-ext:run-program exe
(run-external-program exe
(append actual-args
(list file))
:search t
@ -106,7 +123,7 @@
"-keyout ~a -outform PEM -out ~a")
key-file
cert-file)))
(sb-ext:run-program +openssl-bin+
(run-external-program +openssl-bin+
(text-utils:split-words cmd-args)
:output nil
:error :output)
@ -116,7 +133,7 @@
(croatoan:end-screen)
(with-input-from-string (stream data)
(let ((command-line-splitted (text-utils:split-words program-and-args)))
(sb-ext:run-program (first command-line-splitted)
(run-external-program (first command-line-splitted)
(rest command-line-splitted)
:search t
:wait t
@ -129,7 +146,7 @@
(program (first command-line-splitted))
(args (append (rest command-line-splitted)
(list link))))
(sb-ext:run-program program
(run-external-program program
args
:search t
:wait nil