samedi 29 mars 2014

Configuring a Yasnippet for two scenarios -- (1) region is active; (2) region is not active


Vote count:

0




In conjunction with a user-configuration of (delete-selection-mode 1), is there a way to consolidate the two following Yasnippets into just one snippet so that it will work differently depending upon whether the region is active -- e.g., region-active-p:


Active region -- surround the active region with the snippet:



# -*- mode: snippet -*-
# contributor: lawlist
# key: bold_selected
# name: bold_selected
# binding: C-I b b s
# --
{\bf `yas/selected-text`}


Non-active region -- insert the snippet and place the cursor at the position of $1:



# -*- mode: snippet -*-
# contributor: lawlist
# key: bold
# name: bold
# binding: C-I b b b
# --
{\bf $1}


asked 53 secs ago

lawlist

2,992





Aucun commentaire:

Enregistrer un commentaire