def METHOD_NAME(self, name):
    if self.tool().shorthands.isChecked() and name in shorthands:
        short = shorthands[name]
        # LilyPond >= 2.17.25 changed -| to -!
        if name == 'staccatissimo':
            version = documentinfo.docinfo(self.mainwindow().currentDocument()).version()
            if version >= (2, 17, 25):
                short = '!'
        text = '_-^'[self.direction()+1] + short
    else:
        text = ('_', '', '^')[self.direction()+1] + '\\' + name
    cursor = self.mainwindow().textCursor()
    selection = cursor.hasSelection()
    cursors = articulation_positions(cursor)
    if cursors:
        with cursortools.compress_undo(cursor):
            for c in cursors:
                c.insertText(text)
        if not selection:
            self.mainwindow().currentView().setTextCursor(c)
    elif not selection:
        cursor.insertText(text)