Shortcut for "Move Section" making an (annoying) beep

I have changed the short cut for “Move Section Up” to CMD+ctrl+Up and “Move Section Down” to CMD+ctrl+Down (I use the preferences → keyboard pane), and I detected two issues:

The first thing I notice is that the shorcut only works if it is applied to “All applications” in Preferences → Settings. This is not really a problem right now, but could be for some people.

The second thing: both “Move Up” and “Move Down” work, however, the “Move down” makes a beep, the typical sound of a shorcut not working. The action is indeed performed, but the sound is quite annoying :slight_smile: Any ideas?

Thanks!

PS. I asked about that a year ago, maybe there are any news.

Two approaches come to mind. An easier one, and a better one : - )

The easier approach might be to make a couple of application-specific keyboard assignments through something like Keyboard Maestro:

The specifics would look something like this:

( substituting moveBranchesUpmoveBranchesDown for the mirror case ).

The better approach (faster keystroke performance, more learning, less spending) is probably to make two new keymap assignments inside a very small FoldingText plugin:

You can get to the steps and some sample code through the FT menu with:

FoldingText > Help > Software Development Kit > Documentation > Create Plugins

or

file:///Applications/FoldingText.app/Contents/Resources/dist/sdk/docs/tutorial-Plugins.html

The default editor.addKeyMap entries for branch movement are:

    'Ctrl-Alt-Left': 'moveBranchesLeft',
    'Ctrl-Alt-Right': 'moveBranchesRight',
    'Ctrl-Alt-Up': 'moveBranchesUp',
    'Ctrl-Alt-Down': 'moveBranchesDown'

and your plugin could just make a couple of additional mappings on the pattern of:

    'Cmd-Ctrl-Up': 'moveBranchesUp',
    'Cmd-Ctrl-Down':'moveBranchesDown'

e.g. the main.js file might just contain:

define(function (require, exports, module) {
	var Extensions = require('ft/core/extensions').Extensions;
	Extensions.addInit(function (editor) {
		editor.addKeyMap({
			'Cmd-Ctrl-Up': 'moveBranchesUp',
			'Cmd-Ctrl-Down': 'moveBranchesDown'
		});
	});
});

(adding any other key-mappings which you happen to want, delimited by commas)

and the package.json might be something like:

{
	"name": "Add some custom keyboard shortcuts",
	"version": "1.0.0",
	"description": "Various custom keyboard shortcuts",
	"engines": {
		"foldingtext": ">=2.0.0",
		"taskpaper": ">=3.0.0"
	},
	"homepage": ""
}

(Note that the modifier key format requires any modifiers to be in this format and sequence:

Shift-Cmd-Ctrl-Alt

( See http://codemirror.net/doc/manual.html#keymaps )

PS to get a list of all the internal command names (and any keys mapped to them) into the clipboard, you could run this applescript in Script Editor (OS X 10.10) or Applescript Editor (OS X 10.9)

property pstrJS : "

	function (editor) {
		var lstCmd = editor.commands(),
			lstMaps = [],
			dctCmd,
			strKey;
	
		for (lng = lstCmd.length, i = 0; i < lng; i++) {
			dctCmd = lstCmd[i];
			strKey = dctCmd.shortcut;
			if (strKey) lstMaps.push(dctCmd.name + '\\t' + strKey);
			else lstMaps.push(dctCmd.name);
		}
		lstMaps.sort();
		return lstMaps.join('\\n');
	}
"

tell application "FoldingText"
	set lstDocs to documents
	if lstDocs is not {} then
		tell item 1 of lstDocs to set strCommands to (evaluate script pstrJS)
		set the clipboard to strCommands
		return strCommands
	end if
end tell

Thanks complexpoint, I have been able to change the shortcut using MacOS preferences.

The new shortcut works fine (Cmd-ctrl-down for MoveDown) but it makes a beep when performing the action. Is the typical sound you hear when a shortcut do not work in the current context, but I am getting it even if it works. Estrange enough, Cmd-ctrl-up of MoveUp work without beep.

I think I can live with the beep, though.

Forgive me – I didn’t make myself clear:

You need to clear the system-wide System Preferences setting which you made. The beep is arising from some kind of clash.

To get rid of the beep:

  1. Remove the Sys Prefs setting which you made for the whole computer, and
  2. use one of the two methods above, preferably the plugin method, to make a keyboard assignment specifically for FoldingText.
  3. That’s it. You should now have beep-free local keyboard assignments.

(Both methods work without beeps for those assignments on my system, but the Keyboard Maestro script assignment is just a little slower to respond).

correction only the KeyBoard Maestro method suppresses the beep (see below)

Correction : - )

The Keyboard Maestro technique does indeed remove the beep, but with the plugin method the beep persists …

(one was masking the other on my system, when I cleared the KM setting the beep returned)

Certainly intriguing - I will look at it more closely : - )

Ah …

It looks like this is a known problem with Mac OS X in general:

https://github.com/adobe/brackets/issues/2419

So I’m afraid that I only see two obvious ways forward for the moment

  1. The Keyboard Maestro script assignment
  2. A different pair of keyboard assignments ?

Good luck !

Rob

Thanks for your help. I will consider Keyboard Maestro, which I didn’t know :slight_smile: