How to kill a quoted string at point in emacs?

Posted by user1350992 on Stack Overflow See other posts from Stack Overflow or by user1350992
Published on 2012-07-04T15:13:23Z Indexed on 2012/07/04 15:15 UTC
Read the original article Hit count: 138

Filed under:
|

I would like to kill a quoted string in a source file without having to mark the beginning of the string and kill-region, but just by placing the point anywhere inside the quoted string and pressing a shortcut.

I tried to write a function in elisp for this, but I figured out that the file would need to be parsed from the beginning up to point to determine whether the point is inside quoted string, and to find the bounds of the quoted string(also handle the \")...

But the file is already parsed by font-lock. So now I can find out if I'm inside quoted string:

(defun inside-quoted-string? ()
  (interactive)
  (print (find 'font-lock-doc-face (text-properties-at (point)))))

But how do I get the bounds of the string? font-lock knows it, since it nicely highlights it in blue, but how do I get it?

© Stack Overflow or respective owner

Related posts about emacs

Related posts about elisp