* transpose-sexps @ 2007-01-04 21:34 Paul Pogonyshev 2007-01-04 21:48 ` transpose-sexps Stuart D. Herring 0 siblings, 1 reply; 15+ messages in thread From: Paul Pogonyshev @ 2007-01-04 21:34 UTC (permalink / raw) Put this in *scratch*, put point over `f' letter and hit C-M-t: "t" "f" I get this: "tf" "" which I consider utterly improper. Moreover, it differs from what I get by M-t. Given the recent bug I discovered in Python mode, looks like sexp scanning has been broken. Paul ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: transpose-sexps 2007-01-04 21:34 transpose-sexps Paul Pogonyshev @ 2007-01-04 21:48 ` Stuart D. Herring 2007-01-04 22:02 ` transpose-sexps Paul Pogonyshev 0 siblings, 1 reply; 15+ messages in thread From: Stuart D. Herring @ 2007-01-04 21:48 UTC (permalink / raw) Cc: emacs-devel > Put this in *scratch*, put point over `f' letter and hit C-M-t: > > "t" "f" > > I get this: > > "tf" "" > > which I consider utterly improper. Moreover, it differs from what > I get by M-t. See the doc: Like M-t but applies to sexps. Does not work on a sexp that point is in the middle of if it is a list or string. It assumes that you are outside of strings or lists, so it saw " " and f as your two sexps, and exchanged them. It's just confusing that it looks like the f was moved into the other string. Davis -- This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: transpose-sexps 2007-01-04 21:48 ` transpose-sexps Stuart D. Herring @ 2007-01-04 22:02 ` Paul Pogonyshev 2007-01-04 22:49 ` transpose-sexps Stuart D. Herring ` (2 more replies) 0 siblings, 3 replies; 15+ messages in thread From: Paul Pogonyshev @ 2007-01-04 22:02 UTC (permalink / raw) Stuart D. Herring wrote: > It assumes that you are outside of strings or lists, so it saw > " " > and > f > as your two sexps, and exchanged them. It's just confusing that it looks > like the f was moved into the other string. It's not just confusing, it's a bug. If it doesn't work and this is not (easily) fixable, make it do nothing or report an error. Producing confusing results is worse than doing nothing. Paul ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: transpose-sexps 2007-01-04 22:02 ` transpose-sexps Paul Pogonyshev @ 2007-01-04 22:49 ` Stuart D. Herring 2007-01-04 22:53 ` transpose-sexps Andreas Schwab 2007-01-05 0:30 ` transpose-sexps Richard Stallman 2 siblings, 0 replies; 15+ messages in thread From: Stuart D. Herring @ 2007-01-04 22:49 UTC (permalink / raw) Cc: emacs-devel > It's not just confusing, it's a bug. If it doesn't work and this is not > (easily) fixable, make it do nothing or report an error. Producing > confusing > results is worse than doing nothing. > > Paul In the list case, it's not a bug, because it's impossible to guess the user's intentions. In (-!-foo bar) (baz spam) with point as always at -!-, is the "current sexp" (to be transposed with the following one) the symbol foo, or the list (foo bar)? For the string case, it would be possible to "fix" this, but to do nothing or report an error requires detecting the case just as much as doing the right thing. It is the detection which is hard -- just ask the CC mode people trying to sort out defun detection. Even in Lisp it's equivalent to asking how many unescaped " characters precede point, not counting those in comments (whose identification itself requires counting " in the same manner). Perhaps some clever caching or hints from the user could make that reasonable to implement, but there is no useful change at all that is easily made. Davis -- This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: transpose-sexps 2007-01-04 22:02 ` transpose-sexps Paul Pogonyshev 2007-01-04 22:49 ` transpose-sexps Stuart D. Herring @ 2007-01-04 22:53 ` Andreas Schwab 2007-01-04 23:28 ` transpose-sexps Paul Pogonyshev 2007-01-05 0:30 ` transpose-sexps Richard Stallman 2 siblings, 1 reply; 15+ messages in thread From: Andreas Schwab @ 2007-01-04 22:53 UTC (permalink / raw) Cc: emacs-devel Paul Pogonyshev <pogonyshev@gmx.net> writes: > Stuart D. Herring wrote: >> It assumes that you are outside of strings or lists, so it saw >> " " >> and >> f >> as your two sexps, and exchanged them. It's just confusing that it looks >> like the f was moved into the other string. > > It's not just confusing, it's a bug. If it doesn't work and this is not > (easily) fixable, make it do nothing or report an error. Producing confusing > results is worse than doing nothing. How can you know that " " and f aren't actually the sexps that are supposed to be transposed? Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: transpose-sexps 2007-01-04 22:53 ` transpose-sexps Andreas Schwab @ 2007-01-04 23:28 ` Paul Pogonyshev 2007-01-05 9:13 ` transpose-sexps Miles Bader 2007-01-05 9:38 ` transpose-sexps Andreas Schwab 0 siblings, 2 replies; 15+ messages in thread From: Paul Pogonyshev @ 2007-01-04 23:28 UTC (permalink / raw) Cc: Andreas Schwab Andreas Schwab wrote: > Paul Pogonyshev <pogonyshev@gmx.net> writes: > > > Stuart D. Herring wrote: > >> It assumes that you are outside of strings or lists, so it saw > >> " " > >> and > >> f > >> as your two sexps, and exchanged them. It's just confusing that it looks > >> like the f was moved into the other string. > > > > It's not just confusing, it's a bug. If it doesn't work and this is not > > (easily) fixable, make it do nothing or report an error. Producing confusing > > results is worse than doing nothing. > > How can you know that " " and f aren't actually the sexps that are > supposed to be transposed? As long as other other "sexp" is empty it doesn't make sense to "transpose" with it. Humans are not computers, they will get only confused by it. Or what do you mean by " " sexp? Paul ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: transpose-sexps 2007-01-04 23:28 ` transpose-sexps Paul Pogonyshev @ 2007-01-05 9:13 ` Miles Bader 2007-01-05 20:02 ` transpose-sexps Paul Pogonyshev 2007-01-08 18:00 ` transpose-sexps Stuart D. Herring 2007-01-05 9:38 ` transpose-sexps Andreas Schwab 1 sibling, 2 replies; 15+ messages in thread From: Miles Bader @ 2007-01-05 9:13 UTC (permalink / raw) Cc: Andreas Schwab, emacs-devel Paul Pogonyshev <pogonyshev@gmx.net> writes: > As long as other other "sexp" is empty it doesn't make sense to > "transpose" with it. Humans are not computers, they will get only > confused by it. Or what do you mean by " " sexp? A string is an sexp. " " is a string containing a single space. Emacs sees on the left side of point, a sexp: " ", and on the right side of point, another sexp: f. It swaps them. That's what the command does. [Maybe, as Richard mentioned, it should be more friendly by detecting that it's inside a string and do... something... in that case (what??), but detecting that is not particularly trivial (and so is not a suitable change just before a release).] -Miles -- Come now, if we were really planning to harm you, would we be waiting here, beside the path, in the very darkest part of the forest? ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: transpose-sexps 2007-01-05 9:13 ` transpose-sexps Miles Bader @ 2007-01-05 20:02 ` Paul Pogonyshev 2007-01-08 18:06 ` transpose-sexps Stuart D. Herring 2007-01-08 18:00 ` transpose-sexps Stuart D. Herring 1 sibling, 1 reply; 15+ messages in thread From: Paul Pogonyshev @ 2007-01-05 20:02 UTC (permalink / raw) Cc: Andreas Schwab Miles Bader wrote: > Paul Pogonyshev <pogonyshev@gmx.net> writes: > > As long as other other "sexp" is empty it doesn't make sense to > > "transpose" with it. Humans are not computers, they will get only > > confused by it. Or what do you mean by " " sexp? > > A string is an sexp. " " is a string containing a single space. > > Emacs sees on the left side of point, a sexp: " ", and on the right side > of point, another sexp: f. It swaps them. That's what the command > does. I see now. > [Maybe, as Richard mentioned, it should be more friendly by detecting > that it's inside a string and do... something... in that case (what??), > but detecting that is not particularly trivial (and so is not a suitable > change just before a release).] It is probably possible to ask current major mode if we are in a string. If it is not possible, than it is probably worth it to invent a consistent interface that major modes would implement. I agree that it is not to be done now, of course. (And while I'm at it, it's a pity that "now" spans the last two years or so.) Paul ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: transpose-sexps 2007-01-05 20:02 ` transpose-sexps Paul Pogonyshev @ 2007-01-08 18:06 ` Stuart D. Herring 2007-01-08 21:16 ` transpose-sexps Paul Pogonyshev 0 siblings, 1 reply; 15+ messages in thread From: Stuart D. Herring @ 2007-01-08 18:06 UTC (permalink / raw) Cc: Andreas Schwab, Miles Bader, emacs-devel > It is probably possible to ask current major mode if we are in a string. > If it is not possible, than it is probably worth it to invent a consistent > interface that major modes would implement. I agree that it is not to be > done now, of course. (And while I'm at it, it's a pity that "now" spans > the last two years or so.) Again, this is not a question of inventiveness, consistency, or any other kind of design or programming at all. It's a mathematical question, really: it is easy to ask the question and to devise a mechanism for doing so, but it is algorithmically non-trivial to determine the answer. As Richard has said, it might be possible to use the (new, complicated) syntax caching support to answer this question in a reasonable amount of time, at which point we can consider making C-M-t consult that. Davis -- This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: transpose-sexps 2007-01-08 18:06 ` transpose-sexps Stuart D. Herring @ 2007-01-08 21:16 ` Paul Pogonyshev 2007-01-08 21:22 ` transpose-sexps Stuart D. Herring 0 siblings, 1 reply; 15+ messages in thread From: Paul Pogonyshev @ 2007-01-08 21:16 UTC (permalink / raw) Cc: Andreas Schwab, Miles Bader Stuart D. Herring wrote: > > It is probably possible to ask current major mode if we are in a string. > > If it is not possible, than it is probably worth it to invent a consistent > > interface that major modes would implement. I agree that it is not to be > > done now, of course. (And while I'm at it, it's a pity that "now" spans > > the last two years or so.) > > Again, this is not a question of inventiveness, consistency, or any other > kind of design or programming at all. It's a mathematical question, > really: it is easy to ask the question and to devise a mechanism for doing > so, but it is algorithmically non-trivial to determine the answer. According to Stefan Monier, you can already ask `syntax-ppss'. And that function already does some caching if I was to say from its code. Paul ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: transpose-sexps 2007-01-08 21:16 ` transpose-sexps Paul Pogonyshev @ 2007-01-08 21:22 ` Stuart D. Herring 2007-01-09 2:08 ` transpose-sexps Stefan Monnier 0 siblings, 1 reply; 15+ messages in thread From: Stuart D. Herring @ 2007-01-08 21:22 UTC (permalink / raw) Cc: Andreas Schwab, Miles Bader, emacs-devel >> > It is probably possible to ask current major mode if we are in a >> string. >> > If it is not possible, than it is probably worth it to invent a >> consistent >> > interface that major modes would implement. I agree that it is not to >> be >> > done now, of course. (And while I'm at it, it's a pity that "now" >> spans >> > the last two years or so.) >> >> Again, this is not a question of inventiveness, consistency, or any >> other >> kind of design or programming at all. It's a mathematical question, >> really: it is easy to ask the question and to devise a mechanism for >> doing >> so, but it is algorithmically non-trivial to determine the answer. > > According to Stefan Monier, you can already ask `syntax-ppss'. And that > function already does some caching if I was to say from its code. > > Paul The half of my message you did not include more or less said precisely that, although I did not name but rather described the function. The point is that I don't know whether `syntax-ppss' is always accurate enough and fast enough for us to want to include it in every call to `transpose-sexps'; I believe it is still somewhat "beta". The point is also that the solution you initially proposed ("to invent a consistent interface that major modes would implement" if there was not already one) seems to imply that the problem is one of providing a useful interface to obvious, extant, simple functionality rather than of implementing/applying a parser with a complicated time-space tradeoff. I thought you would want to know that there was a reason for the status quo, even if it was merely "the alternatives are impractical", instead of it merely being an oversight or coding bug. Davis -- This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: transpose-sexps 2007-01-08 21:22 ` transpose-sexps Stuart D. Herring @ 2007-01-09 2:08 ` Stefan Monnier 0 siblings, 0 replies; 15+ messages in thread From: Stefan Monnier @ 2007-01-09 2:08 UTC (permalink / raw) Cc: Andreas Schwab, Miles Bader, emacs-devel, Paul Pogonyshev > The half of my message you did not include more or less said precisely > that, although I did not name but rather described the function. The > point is that I don't know whether `syntax-ppss' is always accurate enough > and fast enough for us to want to include it in every call to > `transpose-sexps'; I believe it is still somewhat "beta". It's not even obvious to me that this is what we'd want. Sometimes, yes, but I commonly use C-M-t to transpose symbols within strings and comments. Stefan ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: transpose-sexps 2007-01-05 9:13 ` transpose-sexps Miles Bader 2007-01-05 20:02 ` transpose-sexps Paul Pogonyshev @ 2007-01-08 18:00 ` Stuart D. Herring 1 sibling, 0 replies; 15+ messages in thread From: Stuart D. Herring @ 2007-01-08 18:00 UTC (permalink / raw) Cc: Andreas Schwab, emacs-devel, Paul Pogonyshev > [Maybe, as Richard mentioned, it should be more friendly by detecting > that it's inside a string and do... something... in that case (what??), > but detecting that is not particularly trivial (and so is not a suitable > change just before a release).] I can answer the "what??": the same thing it does when it's inside a sexp that's a symbol: transpose the string/symbol containing point and the sexp following that. This is the convention also followed by M-t. Sometimes confusion arises because [C-]M-t at the beginning of a word [sexp] exchanges it with the previous one, so that for these commands an object includes the point position that begins the next object. `transpose-sentences' behaves similarly. More confusion: C-x C-t trades current and previous line whether or not point is at the beginning of a line (which is inconsistent either in direction or in the defined extent of each line), and `transpose-paragraphs' trades current paragraph with the next one even if point is just at its beginning, but trades previous and next if point is between two. Davis -- This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: transpose-sexps 2007-01-04 23:28 ` transpose-sexps Paul Pogonyshev 2007-01-05 9:13 ` transpose-sexps Miles Bader @ 2007-01-05 9:38 ` Andreas Schwab 1 sibling, 0 replies; 15+ messages in thread From: Andreas Schwab @ 2007-01-05 9:38 UTC (permalink / raw) Cc: emacs-devel Paul Pogonyshev <pogonyshev@gmx.net> writes: > As long as other other "sexp" is empty I don't see any empty sexp here. > it doesn't make sense to > "transpose" with it. Humans are not computers, they will get only > confused by it. Or what do you mean by " " sexp? See Stuart's mail. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: transpose-sexps 2007-01-04 22:02 ` transpose-sexps Paul Pogonyshev 2007-01-04 22:49 ` transpose-sexps Stuart D. Herring 2007-01-04 22:53 ` transpose-sexps Andreas Schwab @ 2007-01-05 0:30 ` Richard Stallman 2 siblings, 0 replies; 15+ messages in thread From: Richard Stallman @ 2007-01-05 0:30 UTC (permalink / raw) Cc: emacs-devel It's not just confusing, it's a bug. The Emacs sexp commands assume that point is not inside a string. That is not a bug. It might now be possible to use syntax-ppss to make it smarter. We should not think about that now, however. ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2007-01-09 2:08 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-01-04 21:34 transpose-sexps Paul Pogonyshev 2007-01-04 21:48 ` transpose-sexps Stuart D. Herring 2007-01-04 22:02 ` transpose-sexps Paul Pogonyshev 2007-01-04 22:49 ` transpose-sexps Stuart D. Herring 2007-01-04 22:53 ` transpose-sexps Andreas Schwab 2007-01-04 23:28 ` transpose-sexps Paul Pogonyshev 2007-01-05 9:13 ` transpose-sexps Miles Bader 2007-01-05 20:02 ` transpose-sexps Paul Pogonyshev 2007-01-08 18:06 ` transpose-sexps Stuart D. Herring 2007-01-08 21:16 ` transpose-sexps Paul Pogonyshev 2007-01-08 21:22 ` transpose-sexps Stuart D. Herring 2007-01-09 2:08 ` transpose-sexps Stefan Monnier 2007-01-08 18:00 ` transpose-sexps Stuart D. Herring 2007-01-05 9:38 ` transpose-sexps Andreas Schwab 2007-01-05 0:30 ` transpose-sexps Richard Stallman
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.