(defvar *cars-makes* '("Acura" "Alfa Romeo" "Audi" "BMW" "Buick" "Cadillac" "Chevrolet" "Chrysler" "Dodge" "Ferrari" "Fiat" "Ford" "GMC" "Genesis" "Honda" "Hyundai" "INEOS" "INFINITI" "Jaguar" "Jeep" "Kia" "Land Rover" "Lexus" "Lincoln" "MAZDA" "MINI" "Maserati" "Mercedes-Benz" "Mitsubishi" "Nissan" "Porsche" "RAM" "Subaru" "Tesla" "Toyota" "Volkswagen" "Volvo")) (defvar *cars-topics* '("Overview" "Trim Levels" "Performance" "Interior" "Exterior" "Technology")) (defvar *cars-template-model-history* nil) (add-to-list 'savehist-additional-variables '*cars-template-mode-history*) (defun read-cars-template-info () (list (number-to-string (read-number "Model Year: " (1+ (decoded-time-year (decode-time (current-time)))))) (completing-read "Make: " *cars-makes* nil 'confirm) (read-string "Model: " nil *cars-template-model-history*) (completing-read "Topic: " *cars-topics* nil 'confirm))) (defun insert-lines (&rest lines) "Insert LINES separated by newlines. If a LINE is a list, concatenate it before inserting." (dolist (line lines) (if (stringp line) (insert line "\n") (insert (apply #'concat line) "\n")))) (defun slugify (&rest strings) (mapconcat #'downcase strings "-")) (defun cars-template (year make model topic) "Make a new template for Cars.com." (interactive (read-cars-template-info)) (let ((full (mapconcat #'identity (list year make model topic) " ")) (slug (slugify year make model topic))) (insert-lines "**Keywords**: " "" (list "**Meta title**: " full " | %%di_name%%") "" "**Meta description**: " "" (list "**Page slug**: " "/" slug "/") "" "**Image shortcode**: " "" (list "**Buttons**: `
`") "" (list "# " full) "")) (markdown-mode)) (global-hungry-delete-mode) (defun redden () "Redden word at point or the current region." (interactive) (markdown-wrap-or-insert "" "")) (with-eval-after-load 'markdown-mode (define-key markdown-mode-map (kbd "C-c r") #'redden)) (defun remove-linebreaks () "Remove all markdown linebreaks from buffer." (interactive) (save-excursion (goto-char (point-min)) (while (re-search-forward " $" (point-max) :noerror) (hungry-delete-backward 1))))