From ec5b1f2ad0e41de7aa0b4411d8ad10522f9bc8f9 Mon Sep 17 00:00:00 2001 From: timor Date: Wed, 20 Mar 2019 19:18:01 +0100 Subject: [PATCH] core/core-spacemacs-buffer: move up macro definition --- CHANGELOG.develop | 4 ++-- core/core-spacemacs-buffer.el | 35 ++++++++++++++++++----------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.develop b/CHANGELOG.develop index 9c9eba630..a81b26cc7 100644 --- a/CHANGELOG.develop +++ b/CHANGELOG.develop @@ -2112,8 +2112,8 @@ Other: - Lots of improvement with CI and documentation exporting (thanks to Eugene Yaremenko) - Various code and style improvements (thanks to bmag, duianto, Eivind Fonn, - Eugene Yaremenko, Fabien Dubosson, Kalle Lindqvist, Boris Buliga, yuhan0, - thanhvg, Sylvain Benner) + Eugene Yaremenko, Fabien Dubosson, Kalle Lindqvist, Boris Buliga, timor, + yuhan0, thanhvg, Sylvain Benner) - Multiple unit test improvements (thanks to Sylvain Benner, et2010 and Codruț Constantin Gușoi) - Various documentation improvements (thanks Aaron Jensen, Aaron Peckham, Aaron diff --git a/core/core-spacemacs-buffer.el b/core/core-spacemacs-buffer.el index abe1466a1..9049ff531 100644 --- a/core/core-spacemacs-buffer.el +++ b/core/core-spacemacs-buffer.el @@ -267,6 +267,24 @@ Insert it in the first line of the buffer, right justified." (length build-rhs))) (insert "\n")))))) +(defmacro spacemacs-buffer||notes-adapt-caption-to-width (caption + caption-length + width) + "Adapt caption string's length to the note's frame current width. +For internal use in `spacemacs-buffer//notes-render-framed-text'. +CAPTION: string to be encrusted onto the note's frame +CAPTION-LENGTH: length of the caption +WIDTH: current external width of the note's frame." + `(when (> ,caption-length (- ,width 6)) ; minimum frame width is 6 + (if (> ,width 8) + (setq ,caption (concat (substring ,caption + 0 + (min -3 (- (- ,width 6 3) + ,caption-length))) + "...")) + (setq ,caption nil + ,caption-length 0)))) + (defun spacemacs-buffer//notes-render-framed-text (content &optional topcaption botcaption hpadding max-width min-width) "Return a formatted string framed with curved lines. @@ -334,23 +352,6 @@ MIN-WIDTH is the minimal width of the frame, frame included. The frame will not (make-string (max 0 (- width (if botcaption 6 4) botcaption-length)) ?─) "─╯" (when botcaption "\n"))))) -(defmacro spacemacs-buffer||notes-adapt-caption-to-width (caption - caption-length - width) - "Adapt caption string's length to the note's frame current width. -For internal use in `spacemacs-buffer//notes-render-framed-text'. -CAPTION: string to be encrusted onto the note's frame -CAPTION-LENGTH: length of the caption -WIDTH: current external width of the note's frame." - `(when (> ,caption-length (- ,width 6)) ; minimum frame width is 6 - (if (> ,width 8) - (setq ,caption (concat (substring ,caption - 0 - (min -3 (- (- ,width 6 3) - ,caption-length))) - "...")) - (setq ,caption nil - ,caption-length 0)))) (defun spacemacs-buffer//notes-render-framed-line (line width hpadding) "Return a formatted LINE with borders of a frame on each side.