šŸ’¾ Archived View for idiomdrottning.org ā€ŗ zw-slash captured on 2023-05-24 at 18:32:46. Gemini links have been rewritten to link to archived content

View Raw

More Information

ā¬…ļø Previous capture (2021-12-03)

-=-=-=-=-=-=-

Zero-width spaces

I found that sometimes when I post long words I kind of want them to be able to break at slashes or hyphens in narrow windows. To do that, I can insert a unicode zero-width space after the slash.

For emacs, hereā€™s a liā€™l Emacs thing you can set to whatever. Without a prefix, it inserts a slash and a zero-width space. With a prefix, it asks you for another character instead of the slash.

(defun zw-slash (pref)
  (interactive "P")
  (if pref (quoted-insert 1) (insert "/"))
  (insert-char ?\u200B))

Thereā€™s also something called a soft hyphen in case you have long words without any punctuation, like AsĀ­moĀ­raĀ­noĀ­marĀ­diĀ­caĀ­daistiĀ­naĀ­culdaĀ­car.

(defun soft-hyphenate-region (beginning end)
  "Turn hyphens into soft hyphens in region"
  (interactive "*r")
  (save-excursion
    (goto-char beginning)
    (while (search-forward "-" end t)
      (replace-match "Ā­"))))

This one Iā€™m not gonna bind because I donā€™t think Iā€™ll use it often but itā€™s nice to have available in the M-x repertoire.