Reputation: 1321
I'm trying to get a strikethrough to work in terminal emacs. When I add a strikethrough via the face
route, nothing happens. I can, however, paste text with a strikethrough into emacs and it renders correctly. When I describe-char
on it, it says (done with ):i
Composed with the following character(s) "̶" by these characters:
i (#x69)
- (#x336)
I know that many terminals can't handle strikethroughs, but I know mine can, because you can paste them into it. I'm struggling to understand why editing the face doesn't work but I can paste strikethroughs in.
Upvotes: 2
Views: 654
Reputation: 9427
It sounds like you want to insert composing characters to strike out, such that you're changing the contents of the buffer. I don't think I got all the corner cases, but this is a start:
(defun strikeout-region (b e)
"Use \"COMBINING LONG STROKE OVERLAY\" unicode char to strike out the region."
(interactive "r")
(when (use-region-p)
(save-mark-and-excursion
(goto-char b)
(while (and (<= (point) e)
(not (eobp)))
(unless (looking-back "[[:space:]]" (1- (point)))
(insert-char #x336)
(setq e (1+ e)))
(forward-char 1)))))
But maybe you're trying to display a certain face (as set through e.g. font-lock), then setting the strike-through property is the right way to do this. My terminal (rxvt-unicode) can display the composed characters too, but I can't get it to display a face with strike-through.
Upvotes: 2