org-src: Refactor inline src block fontify lines
* lisp/org-src.el (org-fontify-inline-src-blocks-1): Refactor `org-fontify-inline-src-blocks-1' to bring down the maximum line length. While we're at it, get rid of the debugging `message' call that somehow made its way in, and an unused variable in the `let' statement.
This commit is contained in:
parent
b59ccbf55b
commit
521c534101
|
@ -664,37 +664,46 @@ as `org-src-fontify-natively' is non-nil."
|
|||
|
||||
(defun org-fontify-inline-src-blocks-1 (limit)
|
||||
"Fontify inline src_LANG blocks, from `point' up to LIMIT."
|
||||
(let ((case-fold-search t)
|
||||
(initial-point (point)))
|
||||
(while (re-search-forward "\\_<src_\\([^ \t\n[{]+\\)[{[]?" limit t) ; copied from `org-element-inline-src-block-parser'
|
||||
(let ((case-fold-search t))
|
||||
;; The regexp below is copied from `org-element-inline-src-block-parser'.
|
||||
(while (re-search-forward "\\_<src_\\([^ \t\n[{]+\\)[{[]?" limit t)
|
||||
(let ((beg (match-beginning 0))
|
||||
(lang-beg (match-beginning 1))
|
||||
(lang-end (match-end 1))
|
||||
pt)
|
||||
(font-lock-append-text-property lang-beg lang-end 'face 'org-meta-line)
|
||||
(font-lock-append-text-property beg lang-beg 'face 'shadow)
|
||||
(font-lock-append-text-property beg lang-end 'face 'org-inline-src-block)
|
||||
(font-lock-append-text-property
|
||||
lang-beg lang-end 'face 'org-meta-line)
|
||||
(font-lock-append-text-property
|
||||
beg lang-beg 'face 'shadow)
|
||||
(font-lock-append-text-property
|
||||
beg lang-end 'face 'org-inline-src-block)
|
||||
(setq pt (goto-char lang-end))
|
||||
;; `org-element--parse-paired-brackets' doesn't take a limit, so to
|
||||
;; prevent it searching the entire rest of the buffer we temporarily
|
||||
;; narrow the active region.
|
||||
(save-restriction
|
||||
(narrow-to-region beg (min limit (or (save-excursion (and (search-forward "\n" limit t 2) (point)))
|
||||
(point-max))))
|
||||
(message "buf: %S" (substring-no-properties (buffer-string)))
|
||||
(narrow-to-region beg
|
||||
(min limit (or (save-excursion
|
||||
(and (search-forward"\n" limit t 2)
|
||||
(point)))
|
||||
(point-max))))
|
||||
(when (ignore-errors (org-element--parse-paired-brackets ?\[))
|
||||
(font-lock-append-text-property pt (point) 'face 'org-inline-src-block)
|
||||
(font-lock-append-text-property
|
||||
pt (point) 'face 'org-inline-src-block)
|
||||
(setq pt (point)))
|
||||
(when (ignore-errors (org-element--parse-paired-brackets ?\{))
|
||||
(remove-text-properties pt (point) '(face nil))
|
||||
(font-lock-append-text-property pt (1+ pt) 'face '(org-inline-src-block shadow))
|
||||
(font-lock-append-text-property
|
||||
pt (1+ pt) 'face '(org-inline-src-block shadow))
|
||||
(unless (= (1+ pt) (1- (point)))
|
||||
(if org-src-fontify-natively
|
||||
(org-src-font-lock-fontify-block
|
||||
(buffer-substring-no-properties lang-beg lang-end)
|
||||
(1+ pt) (1- (point)))
|
||||
(font-lock-append-text-property (1+ pt) (1- (point)) 'face 'org-inline-src-block)))
|
||||
(font-lock-append-text-property (1- (point)) (point)'face '(org-inline-src-block shadow))
|
||||
(font-lock-append-text-property
|
||||
(1+ pt) (1- (point)) 'face 'org-inline-src-block)))
|
||||
(font-lock-append-text-property
|
||||
(1- (point)) (point) 'face '(org-inline-src-block shadow))
|
||||
(setq pt (point)))))
|
||||
t)))
|
||||
|
||||
|
|
Loading…
Reference in New Issue