Commit e7a7bc49 authored by David Murray's avatar David Murray
Browse files

Fixed some (of my) logic errors for mode-lines. Non-existent

mode lines now handled less gracelessly.
parent fab40715
...@@ -502,8 +502,9 @@ spaces only.")) ...@@ -502,8 +502,9 @@ spaces only."))
(nreverse pairs))) (nreverse pairs)))
(defun split-attribute-line (line) (defun split-attribute-line (line)
(mapcar (lambda (pair) (split-attribute pair #\:)) (when line
(split-attribute line #\;))) (mapcar (lambda (pair) (split-attribute pair #\:))
(split-attribute line #\;))))
(defun find-attribute-line-position (buffer) (defun find-attribute-line-position (buffer)
(let ((scan (beginning-of-buffer (clone-mark (point buffer))))) (let ((scan (beginning-of-buffer (clone-mark (point buffer)))))
...@@ -540,21 +541,24 @@ spaces only.")) ...@@ -540,21 +541,24 @@ spaces only."))
end-scan))))))))) end-scan)))))))))
(defun get-attribute-line (buffer) (defun get-attribute-line (buffer)
(multiple-value-bind (start-mark end-mark) (find-attribute-line-position buffer) (multiple-value-bind (start-mark end-mark)
(let ((line (buffer-substring buffer (find-attribute-line-position buffer)
(offset start-mark) (when (and start-mark end-mark)
(offset end-mark)))) (let ((line (buffer-substring buffer
(when (>= (length line) 6) (offset start-mark)
(let ((end (search "-*-" line :from-end t :start2 3))) (offset end-mark))))
(when end (when (>= (length line) 6)
(string-trim '(#\Space #\Tab) (subseq line 3 end)))))))) (let ((end (search "-*-" line :from-end t :start2 3)))
(when end
(string-trim '(#\Space #\Tab) (subseq line 3 end)))))))))
(defun replace-attribute-line (buffer new-attribute-line) (defun replace-attribute-line (buffer new-attribute-line)
(let ((full-attribute-line (concatenate 'string (let ((full-attribute-line (concatenate 'string
"-*- " "-*- "
new-attribute-line new-attribute-line
"-*-"))) "-*-")))
(multiple-value-bind (start-mark end-mark) (find-attribute-line-position buffer) (multiple-value-bind (start-mark end-mark)
(find-attribute-line-position buffer)
(cond ((not (null end-mark)) (cond ((not (null end-mark))
;; We have an existing attribute line. ;; We have an existing attribute line.
(delete-region start-mark end-mark) (delete-region start-mark end-mark)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment