Permalink
Browse files

Made indentation consistent across all source files

Raw tabs, displayed with indent 2. Added a section to the README
explaining this, and added emacs & vim modelines to adhere to these
settings.
  • Loading branch information...
timbertson committed Nov 9, 2010
1 parent 4b47686 commit 3fb2429a3a8aa99dd369c5bff91a141a35425cdd
Showing with 868 additions and 852 deletions.
  1. +10 −1 README
  2. +58 −56 context_menu.js
  3. +26 −25 manifest.json
  4. +37 −37 options.js
  5. +275 −274 servers/edit-server.el
  6. +132 −131 servers/pycl.py
  7. +237 −236 textareas.js
  8. +93 −92 xmlcomms.js
View
11 README
@@ -20,13 +20,22 @@ protocol.
This extension is licensed under the GPL v3 and development versions
can be found at: http://github.com/stsquad/emacs_chrome
+Hacking
+=======
+
+This modeline should be used in every source file to keep indentation
+consistent:
+// -*- tab-width:2; indent-tabs-mode:t -*- vim: set noet ts=2:
+This tells both emacs and vim to use actual tab characters, and to
+display tabs as 2 columns wide.
+
History
=======
Dave Hilley [1] wrote the original proof of concept that showed it
could be done. I [2] then hacked around with the Javascript to make
the behaviour more like the classic It's All Text add-on available to
-Firefox.
+Firefox.
[1] http://www.thegibson.org/blog/archives/689
[2] http://www.bennee.com/~alex
View
@@ -1,60 +1,62 @@
+// -*- tab-width:2; indent-tabs-mode:t -*- vim: set noet ts=2:
(function(){
- var edit_msg = {};
-
- function menuClicked(info, tab) {
- if (edit_msg) {
- var tab_port = chrome.tabs.connect(tab.id);
- tab_port.tab = tab;
- handleContentMessages(edit_msg, tab_port);
- }
- }
-
-
- var menu_enabled = false;
-
- function enableContextMenu() {
- if (!menu_enabled) {
- chrome.contextMenus.removeAll();
- chrome.contextMenus.create({
- title: "Edit with Emacs",
- contexts: ["editable"],
- onclick: function(info, tab) {
- menuClicked(info, tab);
- }
- });
- menu_enabled = true;
- }
- }
-
- function disableContextMenu() {
- chrome.contextMenus.removeAll();
- menu_enabled = false;
- }
-
- // Initialize the context menu based on stored options.
- // Also, default to enabled if the setting hasn't been saved before.
- if (localStorage.enable_contextmenu === "true" ||
- !localStorage.hasOwnProperty('enable_contextmenu')) {
- enableContextMenu();
- } else {
- disableContextMenu();
- }
-
-
- function processRequest(request, sender, sendResponse) {
- if (request.type === "menu_target") {
- edit_msg = request.edit_msg;
- } else if (request.type === "enable_contextmenu") {
- if (request.enabled) {
- enableContextMenu();
- } else {
- disableContextMenu();
- }
- }
- sendResponse({});
- }
-
- chrome.extension.onRequest.addListener(processRequest);
+ var edit_msg = {};
+
+ function menuClicked(info, tab) {
+ if (edit_msg) {
+ var tab_port = chrome.tabs.connect(tab.id);
+ tab_port.tab = tab;
+ handleContentMessages(edit_msg, tab_port);
+ }
+ }
+
+
+ var menu_enabled = false;
+
+ function enableContextMenu() {
+ if (!menu_enabled) {
+ chrome.contextMenus.removeAll();
+ chrome.contextMenus.create({
+ title: "Edit with Emacs",
+ contexts: ["editable"],
+ onclick: function(info, tab) {
+ menuClicked(info, tab);
+ }
+ });
+ menu_enabled = true;
+ }
+ }
+
+ function disableContextMenu() {
+ chrome.contextMenus.removeAll();
+ menu_enabled = false;
+ }
+
+ // Initialize the context menu based on stored options.
+ // Also, default to enabled if the setting hasn't been saved before.
+ if (localStorage.enable_contextmenu === "true" ||
+ !localStorage.hasOwnProperty('enable_contextmenu')) {
+ enableContextMenu();
+ } else {
+ disableContextMenu();
+ }
+
+
+ function processRequest(request, sender, sendResponse) {
+ if (request.type === "menu_target") {
+ edit_msg = request.edit_msg;
+ } else if (request.type === "enable_contextmenu") {
+ if (request.enabled) {
+ enableContextMenu();
+ } else {
+ disableContextMenu();
+ }
+ }
+ sendResponse({});
+ }
+
+ chrome.extension.onRequest.addListener(processRequest);
})();
+
View
@@ -1,27 +1,28 @@
+// -*- tab-width:2; indent-tabs-mode:t -*- vim: set noet ts=2:
{
- "name": "Edit with Emacs",
- "version": "1.9",
- "description": "Allow user to edit web-page textareas with Emacs (and other editors).",
- "browser_action": {
- "default_icon": "emacs23-16x16.png"
- },
- "background_page": "background.html",
- "permissions": [
- "tabs",
- "contextMenus",
- "http://127.0.0.1/edit/*"
- ],
- "icons":
- {
- "128" : "emacs.png"
- },
- "options_page" : "options.html",
- "content_scripts": [
- {
- "matches": ["http://*/*", "https://*/*", "file://*/*"],
- "js": ["textareas.js", "jquery-1.4.2.min.js", "jquery.color.js"],
- "run_at": "document_idle",
- "all_frames": true
- }
- ]
+ "name": "Edit with Emacs",
+ "version": "1.9",
+ "description": "Allow user to edit web-page textareas with Emacs (and other editors).",
+ "browser_action": {
+ "default_icon": "emacs23-16x16.png"
+ },
+ "background_page": "background.html",
+ "permissions": [
+ "tabs",
+ "contextMenus",
+ "http://127.0.0.1/edit/*"
+ ],
+ "icons":
+ {
+ "128" : "emacs.png"
+ },
+ "options_page" : "options.html",
+ "content_scripts": [
+ {
+ "matches": ["http://*/*", "https://*/*", "file://*/*"],
+ "js": ["textareas.js", "jquery-1.4.2.min.js", "jquery.color.js"],
+ "run_at": "document_idle",
+ "all_frames": true
+ }
+ ]
}
View
@@ -1,3 +1,4 @@
+// -*- tab-width:2; indent-tabs-mode:t -*- vim: set noet ts=2:
/*
* options.js
*
@@ -10,66 +11,65 @@
// Snarfed from AdThwart, not sure why checkboxes are so trixy
function loadCheckbox(id, config, defaultval) {
- document.getElementById(id).checked = typeof localStorage[config] == "undefined" ? defaultval : localStorage[config] == "true";
+ document.getElementById(id).checked = typeof localStorage[config] == "undefined" ? defaultval : localStorage[config] == "true";
}
function saveCheckbox(id, config) {
- localStorage[config] = document.getElementById(id).checked;
+ localStorage[config] = document.getElementById(id).checked;
}
// Saves options to localStorage
function save_options() {
- localStorage["edit_server_port"] = document.getElementById("port").value;
- saveCheckbox("editbutton", "enable_button");
- saveCheckbox("contextmenu", "enable_contextmenu");
- saveCheckbox("dblclick", "enable_dblclick");
- saveCheckbox("keyshort", "enable_keys");
+ localStorage["edit_server_port"] = document.getElementById("port").value;
+ saveCheckbox("editbutton", "enable_button");
+ saveCheckbox("contextmenu", "enable_contextmenu");
+ saveCheckbox("dblclick", "enable_dblclick");
+ saveCheckbox("keyshort", "enable_keys");
- chrome.extension.sendRequest({
- type: "enable_contextmenu",
- enabled: (localStorage.enable_contextmenu === "true")
- });
+ chrome.extension.sendRequest({
+ type: "enable_contextmenu",
+ enabled: (localStorage.enable_contextmenu === "true")
+ });
- // Update status to let user know options were saved.
- var status = document.getElementById("status");
- status.innerHTML = "Options Saved.";
- setTimeout(function() {
- status.innerHTML = "";
- }, 750);
+ // Update status to let user know options were saved.
+ var status = document.getElementById("status");
+ status.innerHTML = "Options Saved.";
+ setTimeout(function() {
+ status.innerHTML = "";
+ }, 750);
}
// Restores select box state to saved value from localStorage.
function restore_options() {
- var port = localStorage["edit_server_port"];
- if (!port) {
- port = 9292;
- }
- document.getElementById("port").value = port;
- loadCheckbox("editbutton", "enable_button", true);
- loadCheckbox("contextmenu", "enable_contextmenu", true);
- loadCheckbox("dblclick", "enable_dblclick", false);
- loadCheckbox("keyshort", "enable_keys", false);
+ var port = localStorage["edit_server_port"];
+ if (!port) {
+ port = 9292;
+ }
+ document.getElementById("port").value = port;
+ loadCheckbox("editbutton", "enable_button", true);
+ loadCheckbox("contextmenu", "enable_contextmenu", true);
+ loadCheckbox("dblclick", "enable_dblclick", false);
+ loadCheckbox("keyshort", "enable_keys", false);
}
/* Message handling multiplexer */
function localMessageHandler(msg, port) {
- // What was the bidding?
- var cmd = msg.msg;
- if (cmd == "test_result") {
+ // What was the bidding?
+ var cmd = msg.msg;
+ if (cmd == "test_result") {
var status = document.getElementById("server_status");
status.innerHTML = msg.text;
- } else {
+ } else {
console.log("localMessageHandler: un-handled message:"+cmd);
- }
+ }
}
// Test for the presence of an Edit Server
function test_server() {
- var port = chrome.extension.connect();
- var status = document.getElementById("server_status");
- status.innerHTML = "testing...";
- port.onMessage.addListener(localMessageHandler);
- port.postMessage({msg: "test"});
+ var port = chrome.extension.connect();
+ var status = document.getElementById("server_status");
+ status.innerHTML = "testing...";
+ port.onMessage.addListener(localMessageHandler);
+ port.postMessage({msg: "test"});
}
-
Oops, something went wrong.

0 comments on commit 3fb2429

Please sign in to comment.