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)
(when line
(mapcar (lambda (pair) (split-attribute pair #\:)) (mapcar (lambda (pair) (split-attribute pair #\:))
(split-attribute line #\;))) (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)
(find-attribute-line-position buffer)
(when (and start-mark end-mark)
(let ((line (buffer-substring buffer (let ((line (buffer-substring buffer
(offset start-mark) (offset start-mark)
(offset end-mark)))) (offset end-mark))))
(when (>= (length line) 6) (when (>= (length line) 6)
(let ((end (search "-*-" line :from-end t :start2 3))) (let ((end (search "-*-" line :from-end t :start2 3)))
(when end (when end
(string-trim '(#\Space #\Tab) (subseq line 3 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