[Python-mode] edit or navigate code by feature
Eric S. Johansson
esj at harvee.org
Sun Jun 26 17:26:00 CEST 2011
On 6/26/2011 4:09 AM, Andreas Röhler wrote:
> Hi Eric,
overall but I think we're pretty close agreement although sometimes I feel like
conversations about speech recognition goes something like this:
> what about implementing a simplified navigation mode like such:
> just call an object: for example "method", "string", "list" etc.
> Emacs will look if inside such a thing.
> If yes, it marks it as region.
> If not, go forward to the next in buffer.
> Should take the common numeric arguments moving forward or backward.
in walking through some examples, I'll be expressing grammar to Emacs
associations using the notation at the end of the paragraph. That may hopefully
bridge some of the Emacs and speech recognition "magic". As I work on examples,
I realize I don't know enough of the Emacs magic to properly describe the Emacs
function so I'm making it up as I go along. Yes I expect to be corrected. :-) I'll
notation: Spoken -- Emacs -- results
given a line like:
self.calories = self.calories + food_record["calories"]*grams
^ = cursor position
"get method" -- (result-to-knp(ar-method-copy-apt)) -- returns copy of method
name and places it in the cut and paste buffer (is region defined here?).
my expectation would be that it would select the entire word "calories" and the
result would be in the cut and paste buffer (kill ring?) For use later on. I
asked the question about whether or not the region is redefined to be on this
word because that might be useful for some other operation within Emacs. Kinda
messy. Too many side effects to make a comfortable but I haven't seen a better
way that doesn't involve speaking more which is not a better way.
"Get next method" -- (result-to-knp(ar-method-copy-apt 1)) -- go find the next
method which would be the next "calories" to the right.
"Replace [string] index" -- (ar-index-replace-apt type 1)) -- find the next
index and replace it with what's in the cut paste/kill buffer. Encapsulate in
quotes or not depending on what is said.
"Narrow to index" -- (ar-index-narrow-apt) -- find the next index and narrow
edit buffer to index. Note: this model should also apply to things like
arguments and predicates. Should be possible to narrow recursively.
is this making enough sense that I should go through and define the grammar and
> Might deliver shorthands within the new mode, so just saying "brack" instead
> of 'ar-bracket-region-atpt' should be enough than.
don't worry about making Emacs pronounceable. I will handle that in the grammar.
Let's make the functionality work for a small subset to test it out and also
figure out a better method of driving Emacs by voice other than injecting
keystrokes. I'd really like to have a method of getting data out of Emacs other
than the cut and paste buffer.
--- eric "pronoun trouble"
More information about the Python-mode