From 85601f50f236686da662b1b00e01df0a0abe761b Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Wed, 22 Jul 2026 11:10:34 +0200 Subject: Update markdown-mode, rust-mode and yaml-mode. Remove unused snippets --- .emacs.d/lisp/markdown-mode.el | 63 ++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 21 deletions(-) (limited to '.emacs.d/lisp/markdown-mode.el') diff --git a/.emacs.d/lisp/markdown-mode.el b/.emacs.d/lisp/markdown-mode.el index 160975c..08ed4bb 100644 --- a/.emacs.d/lisp/markdown-mode.el +++ b/.emacs.d/lisp/markdown-mode.el @@ -1,12 +1,12 @@ ;;; markdown-mode.el --- Major mode for Markdown-formatted text -*- lexical-binding: t; -*- -;; Copyright (C) 2007-2023 Jason R. Blevins and markdown-mode +;; Copyright (C) 2007-2026 Jason R. Blevins and markdown-mode ;; contributors (see the commit log for details). ;; Author: Jason R. Blevins ;; Maintainer: Jason R. Blevins ;; Created: May 24, 2007 -;; Version: 2.8-alpha +;; Version: 2.9-alpha ;; Package-Requires: ((emacs "28.1")) ;; Keywords: Markdown, GitHub Flavored Markdown, itex ;; URL: https://jblevins.org/projects/markdown-mode/ @@ -2930,22 +2930,21 @@ This may be useful for tables and Pandoc's line_blocks extension." "Return t if PROP from BEGIN to END is equal to one of the given PROP-VALUES. Also returns t if PROP is a list containing one of the PROP-VALUES. Return nil otherwise." - (let (props) - (catch 'found - (dolist (loc (number-sequence begin end)) - (when (setq props (get-text-property loc prop)) - (cond ((listp props) - ;; props is a list, check for membership - (dolist (val prop-values) - (when (memq val props) (throw 'found loc)))) - (t - ;; props is a scalar, check for equality - (dolist (val prop-values) - (when (eq val props) (throw 'found loc)))))))))) + (catch 'found + (let ((loc begin)) + (while (<= loc end) + (when-let* ((props (get-text-property loc prop))) + (if (listp props) + ;; props is a list, check for membership + (dolist (val prop-values) + (when (memq val props) (throw 'found loc))) + (dolist (val prop-values) + (when (eq val props) (throw 'found loc))))) + (setq loc (next-single-property-change loc prop nil (1+ end))))))) (defun markdown-range-properties-exist (begin end props) (cl-loop - for loc in (number-sequence begin end) + for loc from begin to end with result = nil while (not (setq result @@ -3637,12 +3636,31 @@ SEQ may be an atom or a sequence." (add-text-properties fontified-start fontified-end heading-props))))) t)) +(defun markdown--fontify-table-alignment () + "Visually align cell separators of the table line at point. +Hiding markup makes the displayed content of a table cell +narrower than the buffer text, which breaks the column alignment +of tables that are aligned in the source. Give the whitespace +before each cell separator a space display specification +stretching it to the separator's buffer column, so that +separators are displayed at the same column as in the source +regardless of what is hidden before them." + (beginning-of-line) + (while (re-search-forward "[ \t]+|" (line-end-position) t) + (let ((separator (1- (match-end 0)))) + (unless (markdown-inline-code-at-pos-p separator) + (put-text-property + (match-beginning 0) separator + 'display `(space :align-to ,(1- (current-column)))))))) + (defun markdown-fontify-tables (last) (when (re-search-forward "|" last t) (when (markdown-table-at-point-p) (font-lock-append-text-property (line-beginning-position) (min (1+ (line-end-position)) (point-max)) - 'face 'markdown-table-face)) + 'face 'markdown-table-face) + (when (or markdown-hide-markup markdown-hide-urls) + (markdown--fontify-table-alignment))) (forward-line 1) t)) @@ -7799,9 +7817,11 @@ Return the name of the output buffer used." markdown-command exit-code)))) output-buffer-name)) -(defun markdown-standalone (&optional output-buffer-name) +(defun markdown-standalone (&optional output-buffer-name title) "Special function to provide standalone HTML output. -Insert the output in the buffer named OUTPUT-BUFFER-NAME." +Insert the output in the buffer named OUTPUT-BUFFER-NAME. +Set the HTML title to TITLE if provided, otherwise the name of the +output buffer." (interactive) (setq output-buffer-name (markdown output-buffer-name)) (let ((css-path markdown-css-paths)) @@ -7809,7 +7829,7 @@ Insert the output in the buffer named OUTPUT-BUFFER-NAME." (set-buffer output-buffer-name) (setq-local markdown-css-paths css-path) (unless (markdown-output-standalone-p) - (markdown-add-xhtml-header-and-footer output-buffer-name)) + (markdown-add-xhtml-header-and-footer (or title output-buffer-name))) (goto-char (point-min)) (html-mode))) output-buffer-name) @@ -7890,7 +7910,8 @@ When OUTPUT-BUFFER-NAME is given, insert the output in the buffer with that name." (interactive) (browse-url-of-buffer - (markdown-standalone (or output-buffer-name markdown-output-buffer-name)))) + (markdown-standalone (or output-buffer-name markdown-output-buffer-name) + (buffer-name)))) (defun markdown-export-file-name (&optional extension) "Attempt to generate a filename for Markdown output. @@ -9773,7 +9794,7 @@ This function assumes point is on a table." (setq fmt (car fmtspec) fmtspec (cdr fmtspec)) (setq width (car widths) widths (cdr widths)) (if (equal fmt 'c) - (setq cell (concat (make-string (/ (- width (length cell)) 2) ?\s) cell))) + (setq cell (concat (make-string (/ (- width (markdown--string-width cell)) 2) ?\s) cell))) (unless (equal fmt 'r) (setq width (- width))) (format (format " %%%ds " width) cell)) cells "|"))) -- cgit v1.3