summaryrefslogtreecommitdiff
path: root/.emacs.d
diff options
context:
space:
mode:
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/lisp/yasnippet.el255
-rw-r--r--.emacs.d/snippets/prog-mode/comment2
-rw-r--r--.emacs.d/snippets/prog-mode/commentline14
3 files changed, 182 insertions, 89 deletions
diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el
index 76e1d25..47b8ff5 100644
--- a/.emacs.d/lisp/yasnippet.el
+++ b/.emacs.d/lisp/yasnippet.el
@@ -558,6 +558,10 @@ conditions.
558(defvar yas--snippet-id-seed 0 558(defvar yas--snippet-id-seed 0
559 "Contains the next id for a snippet.") 559 "Contains the next id for a snippet.")
560 560
561(defvar yas--original-auto-fill-function nil
562 "The original value of `auto-fill-function'.")
563(make-variable-buffer-local 'yas--original-auto-fill-function)
564
561(defun yas--snippet-next-id () 565(defun yas--snippet-next-id ()
562 (let ((id yas--snippet-id-seed)) 566 (let ((id yas--snippet-id-seed))
563 (cl-incf yas--snippet-id-seed) 567 (cl-incf yas--snippet-id-seed)
@@ -764,6 +768,12 @@ which decides on the snippet to expand.")
764(defvar yas-minor-mode-hook nil 768(defvar yas-minor-mode-hook nil
765 "Hook run when `yas-minor-mode' is turned on.") 769 "Hook run when `yas-minor-mode' is turned on.")
766 770
771(defun yas--auto-fill-wrapper ()
772 (when (and auto-fill-function
773 (not (eq auto-fill-function #'yas--auto-fill)))
774 (setq yas--original-auto-fill-function auto-fill-function)
775 (setq auto-fill-function #'yas--auto-fill)))
776
767;;;###autoload 777;;;###autoload
768(define-minor-mode yas-minor-mode 778(define-minor-mode yas-minor-mode
769 "Toggle YASnippet mode. 779 "Toggle YASnippet mode.
@@ -796,12 +806,17 @@ Key bindings:
796 (set-default name nil) 806 (set-default name nil)
797 (set (make-local-variable name) t))) 807 (set (make-local-variable name) t)))
798 ;; Perform JIT loads 808 ;; Perform JIT loads
799 ;; 809 (yas--load-pending-jits)
800 (yas--load-pending-jits)) 810 ;; Install auto-fill handler.
811 (yas--auto-fill-wrapper) ; Now...
812 (add-hook 'auto-fill-mode-hook #'yas--auto-fill-wrapper)) ; or later.
801 (t 813 (t
802 ;; Uninstall the direct keymaps and the post-command hook 814 ;; Uninstall the direct keymaps, post-command hook, and
803 ;; 815 ;; auto-fill handler.
804 (remove-hook 'post-command-hook #'yas--post-command-handler t) 816 (remove-hook 'post-command-hook #'yas--post-command-handler t)
817 (remove-hook 'auto-fill-mode-hook #'yas--auto-fill-wrapper)
818 (when (local-variable-p 'yas--original-auto-fill-function)
819 (setq auto-fill-function yas--original-auto-fill-function))
805 (setq emulation-mode-map-alists 820 (setq emulation-mode-map-alists
806 (remove 'yas--direct-keymaps emulation-mode-map-alists))))) 821 (remove 'yas--direct-keymaps emulation-mode-map-alists)))))
807 822
@@ -3004,6 +3019,15 @@ Update each field with the result of calling FUN."
3004 (setf (yas--exit-marker snippet-exit) 3019 (setf (yas--exit-marker snippet-exit)
3005 (funcall fun (yas--exit-marker snippet-exit)))))) 3020 (funcall fun (yas--exit-marker snippet-exit))))))
3006 3021
3022(defun yas--snippet-live-p (snippet)
3023 "Return non-nil if SNIPPET hasn't been committed."
3024 (catch 'live
3025 (yas--snippet-map-markers (lambda (m)
3026 (if (markerp m) m
3027 (throw 'live nil)))
3028 snippet)
3029 t))
3030
3007(defun yas--apply-transform (field-or-mirror field &optional empty-on-nil-p) 3031(defun yas--apply-transform (field-or-mirror field &optional empty-on-nil-p)
3008 "Calculate transformed string for FIELD-OR-MIRROR from FIELD. 3032 "Calculate transformed string for FIELD-OR-MIRROR from FIELD.
3009 3033
@@ -3166,7 +3190,11 @@ If there's none, exit the snippet."
3166(defun yas--place-overlays (snippet field) 3190(defun yas--place-overlays (snippet field)
3167 "Correctly place overlays for SNIPPET's FIELD." 3191 "Correctly place overlays for SNIPPET's FIELD."
3168 (yas--make-move-field-protection-overlays snippet field) 3192 (yas--make-move-field-protection-overlays snippet field)
3169 (yas--make-move-active-field-overlay snippet field)) 3193 ;; Only move active field overlays if this is field is from the
3194 ;; innermost snippet.
3195 (when (eq snippet (car (yas-active-snippets (1- (yas--field-start field))
3196 (1+ (yas--field-end field)))))
3197 (yas--make-move-active-field-overlay snippet field)))
3170 3198
3171(defun yas--move-to-field (snippet field) 3199(defun yas--move-to-field (snippet field)
3172 "Update SNIPPET to move to field FIELD. 3200 "Update SNIPPET to move to field FIELD.
@@ -3174,6 +3202,7 @@ If there's none, exit the snippet."
3174Also create some protection overlays" 3202Also create some protection overlays"
3175 (goto-char (yas--field-start field)) 3203 (goto-char (yas--field-start field))
3176 (yas--place-overlays snippet field) 3204 (yas--place-overlays snippet field)
3205 (overlay-put yas--active-field-overlay 'yas--snippet snippet)
3177 (overlay-put yas--active-field-overlay 'yas--field field) 3206 (overlay-put yas--active-field-overlay 'yas--field field)
3178 (let ((number (yas--field-number field))) 3207 (let ((number (yas--field-number field)))
3179 ;; check for the special ${0: ...} field 3208 ;; check for the special ${0: ...} field
@@ -3293,7 +3322,7 @@ This renders the snippet as ordinary text."
3293 (yas--snapshot-marker-location m)) 3322 (yas--snapshot-marker-location m))
3294 (set-marker m nil))) 3323 (set-marker m nil)))
3295 snippet) 3324 snippet)
3296 (let ((ctrl-ov (yas--snapshot-overlay-location 3325 (let ((ctrl-ov (yas--snapshot-overlay-line-location
3297 (yas--snippet-control-overlay snippet)))) 3326 (yas--snippet-control-overlay snippet))))
3298 (push (list ctrl-ov dst-base-line snippet) to-move) 3327 (push (list ctrl-ov dst-base-line snippet) to-move)
3299 (delete-overlay (car ctrl-ov)))) 3328 (delete-overlay (car ctrl-ov))))
@@ -3327,7 +3356,10 @@ This renders the snippet as ordinary text."
3327 (lambda (l-m-r-w) 3356 (lambda (l-m-r-w)
3328 (goto-char base-pos) 3357 (goto-char base-pos)
3329 (forward-line (nth 0 l-m-r-w)) 3358 (forward-line (nth 0 l-m-r-w))
3330 (yas--restore-marker-location (cdr l-m-r-w)) 3359 (save-restriction
3360 (narrow-to-region (line-beginning-position)
3361 (line-end-position))
3362 (yas--restore-marker-location (cdr l-m-r-w)))
3331 (nth 1 l-m-r-w)) 3363 (nth 1 l-m-r-w))
3332 snippet) 3364 snippet)
3333 (goto-char base-pos) 3365 (goto-char base-pos)
@@ -3529,19 +3561,50 @@ field start. This hook does nothing if an undo is in progress."
3529 yas--inhibit-overlay-hooks 3561 yas--inhibit-overlay-hooks
3530 (not (overlayp yas--active-field-overlay)) ; Avoid Emacs bug #21824. 3562 (not (overlayp yas--active-field-overlay)) ; Avoid Emacs bug #21824.
3531 (yas--undo-in-progress)) 3563 (yas--undo-in-progress))
3532 (let* ((inhibit-modification-hooks t) 3564 (let* ((inhibit-modification-hooks nil)
3565 (yas--inhibit-overlay-hooks t)
3533 (field (overlay-get overlay 'yas--field)) 3566 (field (overlay-get overlay 'yas--field))
3534 (snippet (overlay-get yas--active-field-overlay 'yas--snippet))) 3567 (snippet (overlay-get yas--active-field-overlay 'yas--snippet)))
3535 (save-match-data 3568 (if (yas--snippet-live-p snippet)
3536 (yas--letenv (yas--snippet-expand-env snippet) 3569 (save-match-data
3537 (when (yas--skip-and-clear-field-p field beg end length) 3570 (yas--letenv (yas--snippet-expand-env snippet)
3538 ;; We delete text starting from the END of insertion. 3571 (when (yas--skip-and-clear-field-p field beg end length)
3539 (yas--skip-and-clear field end)) 3572 ;; We delete text starting from the END of insertion.
3540 (setf (yas--field-modified-p field) t) 3573 (yas--skip-and-clear field end))
3541 (yas--advance-end-maybe field (overlay-end overlay)) 3574 (setf (yas--field-modified-p field) t)
3542 (save-excursion 3575 (yas--advance-end-maybe field (overlay-end overlay))
3543 (yas--field-update-display field)) 3576 (save-excursion
3544 (yas--update-mirrors snippet)))))) 3577 (yas--field-update-display field))
3578 (yas--update-mirrors snippet)))
3579 (lwarn '(yasnippet zombie) :warning "Killing zombie snippet!")
3580 (delete-overlay overlay)))))
3581
3582(defun yas--auto-fill ()
3583 (let* ((orig-point (point))
3584 (end (progn (forward-paragraph) (point)))
3585 (beg (progn (backward-paragraph) (point)))
3586 (snippets (yas-active-snippets beg end))
3587 (remarkers nil)
3588 (reoverlays nil))
3589 (dolist (snippet snippets)
3590 (dolist (m (yas--collect-snippet-markers snippet))
3591 (push (yas--snapshot-marker-location m beg end) remarkers))
3592 (push (yas--snapshot-overlay-location
3593 (yas--snippet-control-overlay snippet) beg end)
3594 reoverlays))
3595 (goto-char orig-point)
3596 (let ((yas--inhibit-overlay-hooks t))
3597 (funcall yas--original-auto-fill-function))
3598 (save-excursion
3599 (setq end (progn (forward-paragraph) (point)))
3600 (setq beg (progn (backward-paragraph) (point))))
3601 (save-excursion
3602 (save-restriction
3603 (narrow-to-region beg end)
3604 (mapc #'yas--restore-marker-location remarkers)
3605 (mapc #'yas--restore-overlay-location reoverlays))
3606 (mapc #'yas--update-mirrors snippets))))
3607
3545 3608
3546;;; Apropos protection overlays: 3609;;; Apropos protection overlays:
3547;; 3610;;
@@ -3682,17 +3745,10 @@ considered when expanding the snippet."
3682 ;; them mostly to make the undo information 3745 ;; them mostly to make the undo information
3683 ;; 3746 ;;
3684 (setq yas--start-column (current-column)) 3747 (setq yas--start-column (current-column))
3685 (let ((yas--inhibit-overlay-hooks t) 3748 (let ((yas--inhibit-overlay-hooks t))
3686 ;; Avoid major-mode's syntax propertizing function,
3687 ;; since we mess with the syntax-table and also
3688 ;; insert things that are not valid in the
3689 ;; major-mode language syntax anyway.
3690 (syntax-propertize-function nil))
3691 (insert content) 3749 (insert content)
3692 (setq snippet 3750 (setq snippet
3693 (yas--snippet-create expand-env start (point)))) 3751 (yas--snippet-create expand-env start (point)))))
3694 ;; Invalidate any syntax-propertizing done while `syntax-propertize-function' was nil
3695 (syntax-ppss-flush-cache start))
3696 3752
3697 ;; stacked-expansion: This checks for stacked expansion, save the 3753 ;; stacked-expansion: This checks for stacked expansion, save the
3698 ;; `yas--previous-active-field' and advance its boundary. 3754 ;; `yas--previous-active-field' and advance its boundary.
@@ -3731,7 +3787,8 @@ considered when expanding the snippet."
3731 (let ((first-field (car (yas--snippet-fields snippet)))) 3787 (let ((first-field (car (yas--snippet-fields snippet))))
3732 (when first-field 3788 (when first-field
3733 (sit-for 0) ;; fix issue 125 3789 (sit-for 0) ;; fix issue 125
3734 (yas--move-to-field snippet first-field))) 3790 (yas--letenv (yas--snippet-expand-env snippet)
3791 (yas--move-to-field snippet first-field))))
3735 (yas--message 4 "snippet expanded.") 3792 (yas--message 4 "snippet expanded.")
3736 t)))) 3793 t))))
3737 3794
@@ -3941,7 +3998,10 @@ expansion.")
3941necessary fields, mirrors and exit points. 3998necessary fields, mirrors and exit points.
3942 3999
3943Meant to be called in a narrowed buffer, does various passes" 4000Meant to be called in a narrowed buffer, does various passes"
3944 (let ((parse-start (point))) 4001 (let ((parse-start (point))
4002 ;; Avoid major-mode's syntax propertizing function, since we
4003 ;; change the syntax-table while calling `scan-sexps'.
4004 (syntax-propertize-function nil))
3945 ;; Reset the yas--dollar-regions 4005 ;; Reset the yas--dollar-regions
3946 ;; 4006 ;;
3947 (setq yas--dollar-regions nil) 4007 (setq yas--dollar-regions nil)
@@ -4004,7 +4064,10 @@ Meant to be called in a narrowed buffer, does various passes"
4004 ;; indent the best we can 4064 ;; indent the best we can
4005 ;; 4065 ;;
4006 (goto-char parse-start) 4066 (goto-char parse-start)
4007 (yas--indent snippet))) 4067 ;; Invalidate any syntax-propertizing done while
4068 ;; `syntax-propertize-function' was nil.
4069 (syntax-ppss-flush-cache parse-start))
4070 (yas--indent snippet))
4008 4071
4009;; HACK: Some implementations of `indent-line-function' (called via 4072;; HACK: Some implementations of `indent-line-function' (called via
4010;; `indent-according-to-mode') delete text before they insert (like 4073;; `indent-according-to-mode') delete text before they insert (like
@@ -4018,34 +4081,48 @@ Meant to be called in a narrowed buffer, does various passes"
4018;; indentation generally affects whitespace at the beginning, not the 4081;; indentation generally affects whitespace at the beginning, not the
4019;; end. 4082;; end.
4020;; 4083;;
4084;; Two other cases where we apply a similar strategy:
4085;;
4086;; 1. Handling `auto-fill-mode', in this case we need to use the
4087;; current paragraph instead of line.
4088;;
4089;; 2. Moving snippets from an `org-src' temp buffer into the main org
4090;; buffer, in this case we need to count the line offsets (because org
4091;; may add indentation on each line making character positions
4092;; unreliable).
4093;;
4021;; This is all best-effort heuristic stuff, but it should cover 99% of 4094;; This is all best-effort heuristic stuff, but it should cover 99% of
4022;; use-cases. 4095;; use-cases.
4023 4096
4024(defun yas--snapshot-marker-location (marker) 4097(defun yas--snapshot-marker-location (marker &optional beg end)
4025 "Returns info for restoring MARKER's location after indent. 4098 "Returns info for restoring MARKER's location after indent.
4026The returned value is a list of the form (MARKER REGEXP WS-COUNT). 4099The returned value is a list of the form (MARKER REGEXP WS-COUNT)."
4027If MARKER is not on current line, then return nil." 4100 (unless beg (setq beg (line-beginning-position)))
4028 (when (and (<= (line-beginning-position) marker) 4101 (unless end (setq end (line-end-position)))
4029 (<= marker (line-end-position))) 4102 (let ((before (split-string (buffer-substring-no-properties beg marker)
4030 (let ((before 4103 "[[:space:]\n]+" t))
4031 (split-string (buffer-substring-no-properties 4104 (after (split-string (buffer-substring-no-properties marker end)
4032 (line-beginning-position) marker) "[[:space:]]+" t)) 4105 "[[:space:]\n]+" t)))
4033 (after 4106 (list marker
4034 (split-string (buffer-substring-no-properties 4107 (concat "[[:space:]\n]*"
4035 marker (line-end-position)) "[[:space:]]+" t))) 4108 (mapconcat (lambda (s)
4036 (list marker 4109 (if (eq s marker) "\\(\\)"
4037 (concat "[[:space:]]*" 4110 (regexp-quote s)))
4038 (mapconcat (lambda (s) 4111 (nconc before (list marker) after)
4039 (if (eq s marker) "\\(\\)" 4112 "[[:space:]\n]*"))
4040 (regexp-quote s))) 4113 (progn (goto-char marker)
4041 (nconc before (list marker) after) 4114 (skip-syntax-forward " " end)
4042 "[[:space:]]*")) 4115 (- (point) marker)))))
4043 (progn (goto-char marker) 4116
4044 (skip-syntax-forward " " (line-end-position)) 4117(defun yas--snapshot-overlay-location (overlay beg end)
4045 (- (point) marker)))))) 4118 "Like `yas--snapshot-marker-location' for overlays.
4119The returned format is (OVERLAY (RE WS) (RE WS))."
4120 (list overlay
4121 (cdr (yas--snapshot-marker-location (overlay-start overlay) beg end))
4122 (cdr (yas--snapshot-marker-location (overlay-end overlay) beg end))))
4046 4123
4047(defun yas--snapshot-overlay-location (overlay) 4124(defun yas--snapshot-overlay-line-location (overlay)
4048 "Like `yas--snapshot-marker-location', but for overlays. 4125 "Return info for restoring OVERLAY's line based location.
4049The returned format is (OVERLAY (LINE RE WS) (LINE RE WS))." 4126The returned format is (OVERLAY (LINE RE WS) (LINE RE WS))."
4050 (let ((loc-beg (progn (goto-char (overlay-start overlay)) 4127 (let ((loc-beg (progn (goto-char (overlay-start overlay))
4051 (yas--snapshot-marker-location (point)))) 4128 (yas--snapshot-marker-location (point))))
@@ -4058,35 +4135,47 @@ The returned format is (OVERLAY (LINE RE WS) (LINE RE WS))."
4058 (list overlay loc-beg loc-end))) 4135 (list overlay loc-beg loc-end)))
4059 4136
4060(defun yas--goto-saved-location (regexp ws-count) 4137(defun yas--goto-saved-location (regexp ws-count)
4061 "Move point to location saved by `yas--snapshot-marker-location'." 4138 "Move point to location saved by `yas--snapshot-marker-location'.
4062 (beginning-of-line) 4139Buffer must be narrowed to BEG..END used to create the snapshot info."
4063 (save-restriction 4140 (goto-char (point-min))
4064 ;; Narrowing is the only way to limit `looking-at'. 4141 (if (not (looking-at regexp))
4065 (narrow-to-region (point) (line-end-position)) 4142 (lwarn '(yasnippet re-marker) :warning
4066 (if (not (looking-at regexp)) 4143 "Couldn't find: %S" regexp)
4067 (lwarn '(yasnippet re-marker) :warning 4144 (goto-char (match-beginning 1))
4068 "Couldn't find: %S" regexp) 4145 (skip-syntax-forward " ")
4069 (goto-char (match-beginning 1)) 4146 (skip-syntax-backward " " (- (point) ws-count))))
4070 (skip-syntax-forward " ")
4071 (skip-syntax-backward " " (- (point) ws-count)))))
4072 4147
4073(defun yas--restore-marker-location (re-marker) 4148(defun yas--restore-marker-location (re-marker)
4074 "Restores marker based on info from `yas--snapshot-marker-location'. 4149 "Restores marker based on info from `yas--snapshot-marker-location'.
4075Assumes point is currently on the 'same' line as before." 4150Buffer must be narrowed to BEG..END used to create the snapshot info."
4076 (apply #'yas--goto-saved-location (cdr re-marker)) 4151 (apply #'yas--goto-saved-location (cdr re-marker))
4077 (set-marker (car re-marker) (point))) 4152 (set-marker (car re-marker) (point)))
4078 4153
4079(defun yas--restore-overlay-location (ov-locations) 4154(defun yas--restore-overlay-location (ov-locations)
4080 "Restores overlay based on info from `yas--snapshot-overlay-location'." 4155 "Restores marker based on info from `yas--snapshot-marker-location'.
4081 (move-overlay (car ov-locations) 4156Buffer must be narrowed to BEG..END used to create the snapshot info."
4082 (save-excursion 4157 (cl-destructuring-bind (overlay loc-beg loc-end) ov-locations
4083 (forward-line (car (nth 1 ov-locations))) 4158 (move-overlay overlay
4084 (apply #'yas--goto-saved-location (cdr (nth 1 ov-locations))) 4159 (progn (apply #'yas--goto-saved-location loc-beg)
4085 (point)) 4160 (point))
4086 (save-excursion 4161 (progn (apply #'yas--goto-saved-location loc-end)
4087 (forward-line (car (nth 2 ov-locations))) 4162 (point)))))
4088 (apply #'yas--goto-saved-location (cdr (nth 2 ov-locations))) 4163
4089 (point)))) 4164
4165(defun yas--restore-overlay-line-location (ov-locations)
4166 "Restores overlay based on info from `yas--snapshot-overlay-line-location'."
4167 (save-restriction
4168 (move-overlay (car ov-locations)
4169 (save-excursion
4170 (forward-line (car (nth 1 ov-locations)))
4171 (narrow-to-region (line-beginning-position) (line-end-position))
4172 (apply #'yas--goto-saved-location (cdr (nth 1 ov-locations)))
4173 (point))
4174 (save-excursion
4175 (forward-line (car (nth 2 ov-locations)))
4176 (narrow-to-region (line-beginning-position) (line-end-position))
4177 (apply #'yas--goto-saved-location (cdr (nth 2 ov-locations)))
4178 (point)))))
4090 4179
4091(defun yas--indent-region (from to snippet) 4180(defun yas--indent-region (from to snippet)
4092 "Indent the lines between FROM and TO with `indent-according-to-mode'. 4181 "Indent the lines between FROM and TO with `indent-according-to-mode'.
@@ -4097,15 +4186,21 @@ The SNIPPET's markers are preserved."
4097 (goto-char from) 4186 (goto-char from)
4098 (save-restriction 4187 (save-restriction
4099 (widen) 4188 (widen)
4100 (cl-loop if (/= (line-beginning-position) (line-end-position)) do 4189 (cl-loop for bol = (line-beginning-position)
4190 for eol = (line-end-position)
4191 if (/= bol eol) do
4101 ;; Indent each non-empty line. 4192 ;; Indent each non-empty line.
4102 (let ((remarkers 4193 (let ((remarkers nil))
4103 (delq nil (mapcar #'yas--snapshot-marker-location 4194 (dolist (m snippet-markers)
4104 snippet-markers)))) 4195 (when (and (<= bol m) (<= m eol))
4196 (push (yas--snapshot-marker-location m bol eol)
4197 remarkers)))
4105 (unwind-protect 4198 (unwind-protect
4106 (progn (back-to-indentation) 4199 (progn (back-to-indentation)
4107 (indent-according-to-mode)) 4200 (indent-according-to-mode))
4108 (mapc #'yas--restore-marker-location remarkers))) 4201 (save-restriction
4202 (narrow-to-region bol (line-end-position))
4203 (mapc #'yas--restore-marker-location remarkers))))
4109 while (and (zerop (forward-line 1)) 4204 while (and (zerop (forward-line 1))
4110 (< (point) to))))))) 4205 (< (point) to)))))))
4111 4206
diff --git a/.emacs.d/snippets/prog-mode/comment b/.emacs.d/snippets/prog-mode/comment
index edd53e9..7ae2b8c 100644
--- a/.emacs.d/snippets/prog-mode/comment
+++ b/.emacs.d/snippets/prog-mode/comment
@@ -3,4 +3,4 @@
3# name: comment 3# name: comment
4# key: co 4# key: co
5# -- 5# --
6${1:$(yas-trimmed-comment-start)} ${1:comment}${1:$(unless (eq (length comment-end) 0) (concat " " (yas-trimmed-comment-end)))}$0 \ No newline at end of file 6`(yas-trimmed-comment-start)` ${1:comment}`(unless (eq (length comment-end) 0) (concat " " (yas-trimmed-comment-end)))`$0 \ No newline at end of file
diff --git a/.emacs.d/snippets/prog-mode/commentline b/.emacs.d/snippets/prog-mode/commentline
index 0b0edff..400a7bf 100644
--- a/.emacs.d/snippets/prog-mode/commentline
+++ b/.emacs.d/snippets/prog-mode/commentline
@@ -3,11 +3,9 @@
3# name: commentline 3# name: commentline
4# key: col 4# key: col
5# -- 5# --
6${1:$(yas-trimmed-comment-start)} ${1:comment} ${1:$(let* ((str "") 6`(yas-trimmed-comment-start)` ${1:comment} ${1:$(let* ((start (yas-trimmed-comment-start))
7 (curr (current-column)) 7 (lastcom (aref start (1- (length start))))
8 (start (yas-trimmed-comment-start)) 8 (end (yas-trimmed-comment-end))
9 (lastcom (substring start -1)) 9 (endpadlen (- 79 (+ (current-column) (length end)))))
10 (end (yas-trimmed-comment-end))) 10 (concat (make-string (max endpadlen 0) lastcom)
11 (while (< (length str) (- 79 (+ curr (length end)))) 11 end))}$0 \ No newline at end of file
12 (setq str (concat str lastcom)))
13 (concat str end))}$0 \ No newline at end of file