mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
improved compatibility with Emacs 21.3 -- it doesn't have a function to look up text cursor position.
This commit is contained in:
parent
4c08e75673
commit
445aebe1ed
23
yasnippet.el
23
yasnippet.el
@ -573,14 +573,16 @@ an example:
|
|||||||
|
|
||||||
(defun yas/point-to-coord (&optional point)
|
(defun yas/point-to-coord (&optional point)
|
||||||
"Get the xoffset/yoffset information of POINT.
|
"Get the xoffset/yoffset information of POINT.
|
||||||
If POINT is not given, default is to current point."
|
If POINT is not given, default is to current point.
|
||||||
(let* ((pn (posn-at-point (or point (point))))
|
If `posn-at-point' is not available (like in Emacs 21.3),
|
||||||
(x-y (posn-x-y pn))
|
t is returned simply."
|
||||||
(x (car x-y))
|
(if (boundp 'posn-at-point)
|
||||||
(y (cdr x-y))
|
(let ((x-y (posn-x-y (posn-at-point (or point (point))))))
|
||||||
(coord (list (list (+ x 10) (+ y 20)) (selected-window))))
|
(list (list (+ (car x-y) 10)
|
||||||
coord))
|
(+ (cdr x-y) 20))
|
||||||
|
(selected-window)))
|
||||||
|
t))
|
||||||
|
|
||||||
(defun yas/popup-for-template (templates)
|
(defun yas/popup-for-template (templates)
|
||||||
"Show a popup menu listing templates to let the user select one."
|
"Show a popup menu listing templates to let the user select one."
|
||||||
(if window-system
|
(if window-system
|
||||||
@ -601,8 +603,9 @@ If POINT is not given, default is to current point."
|
|||||||
(dolist (key yas/trigger-keys)
|
(dolist (key yas/trigger-keys)
|
||||||
(global-set-key key 'yas/expand))
|
(global-set-key key 'yas/expand))
|
||||||
(when yas/use-menu
|
(when yas/use-menu
|
||||||
(define-key-after global-map
|
(define-key-after
|
||||||
[menu-bar yasnippet]
|
(lookup-key global-map [menu-bar])
|
||||||
|
[yasnippet]
|
||||||
(cons "YASnippet" yas/menu-keymap)
|
(cons "YASnippet" yas/menu-keymap)
|
||||||
'buffer)))
|
'buffer)))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user