This is like 'filename', but is a full path, and is nil if the file
doesn't exist.
+*** New 'thing-at-point' target: 'list-or-string'.
+This is like 'list', but also prefers to find of any enclosing string.
+
+++
*** New variable 'thing-at-point-provider-alist'.
This allows mode-specific alterations to how 'thing-at-point' works.
`(menu-item "Paste" mouse-yank-at-click
:help "Paste (yank) text most recently cut/copied")))
(when (and (cdr yank-menu) (not buffer-read-only))
- (let ((submenu (make-sparse-keymap (propertize "Paste from Kill Menu"))))
- (dolist (item yank-menu)
+ (let ((submenu (make-sparse-keymap (propertize "Paste from Kill Menu")))
+ (i 0))
+ (dolist (item (reverse yank-menu))
(when (consp item)
- (define-key-after submenu (vector (car item))
+ (define-key submenu (vector (setq i (1+ i)))
`(menu-item ,(cadr item)
,(lambda () (interactive)
(mouse-yank-from-menu click (car item)))))))
`(menu-item "All"
,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'buffer))
:help "Mark the whole buffer for a subsequent cut/copy"))
- (define-key-after submenu [mark-line]
- `(menu-item "Line"
- ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'line))
- :help "Mark the line at click for a subsequent cut/copy"))
(define-key-after submenu [mark-defun]
`(menu-item "Defun"
,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'defun))
:help "Mark the defun at click for a subsequent cut/copy"))
- (define-key-after submenu [mark-list]
- `(menu-item "List"
- ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'list))
- :help "Mark the list at click for a subsequent cut/copy"))
+ (define-key-after submenu [mark-list-or-string]
+ `(menu-item ,(if (nth 8 (syntax-ppss (posn-point (event-end click))))
+ "String" "List")
+ ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'list-or-string))
+ :help "Mark list or string at click for a subsequent cut/copy"))
+ (define-key-after submenu [mark-line]
+ `(menu-item "Line"
+ ,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'line))
+ :help "Mark the line at click for a subsequent cut/copy"))
(define-key-after submenu [mark-symbol]
`(menu-item "Symbol"
,(lambda (e) (interactive "e") (mark-thing-at-mouse e 'symbol))
(put 'list 'bounds-of-thing-at-point 'thing-at-point-bounds-of-list-at-point)
-(defun thing-at-point-bounds-of-list-at-point ()
+(defun thing-at-point-bounds-of-list-at-point (&optional escape-strings no-syntax-crossing)
"Return the bounds of the list at point.
Prefer the enclosing list with fallback on sexp at point.
\[Internal function used by `bounds-of-thing-at-point'.]"
(save-excursion
- (if (ignore-errors (up-list -1))
+ (if (ignore-errors (up-list -1 escape-strings no-syntax-crossing))
(ignore-errors (cons (point) (progn (forward-sexp) (point))))
(let ((bound (bounds-of-thing-at-point 'sexp)))
(and bound
(<= (car bound) (point)) (< (point) (cdr bound))
bound)))))
+(put 'list-or-string 'bounds-of-thing-at-point
+ 'thing-at-point-bounds-of-list-or-string-at-point)
+
+(defun thing-at-point-bounds-of-list-or-string-at-point ()
+ "Return the bounds of the list or string at point.
+Like `thing-at-point-bounds-of-list-at-point', but also
+prefer to find of any enclosing string."
+ (thing-at-point-bounds-of-list-at-point t t))
+
;; Defuns
(put 'defun 'beginning-op 'beginning-of-defun)