all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: python-mode: keep mark when shifting [patch]
@ 2006-03-13  0:22 Dave Love
  2006-03-13 11:34 ` David Reitter
  0 siblings, 1 reply; 9+ messages in thread
From: Dave Love @ 2006-03-13  0:22 UTC (permalink / raw)
  Cc: David Reitter, emacs-devel, henrik.enberg

Richard Stallman <rms@gnu.org> writes:

> In C or Lisp I
> would use C-u TAB to shift a subexpression to the proper position.
> (There's no need to specify left or right, because the command figures
> that out.)  Could that work in Python mode?

There isn't a single correct indentation in general.  (TAB cycles
between the valid values.)

Note that Python mode obeys the Emacs conventions for indentation
commands, unlike Lisp mode.  It just binds `indent-line-function',
which doesn't take an arg.  It would probably make sense for C-u TAB
to re-indent the rest of a block rigidly when used on the head line of
the block, and/or to have TAB act on the region when it's active, but
there are better things to spend time on.

The shift-region functions are inherited from the old python-mode.el
and may or may not really be a good idea.

> I recall Python is weird in regard to indentation.  Maybe it simply
> needs different kinds of commands from those needed by other
> languages.

Python uses something like Landin's offside rule to define blocks by
indentation.  I don't think it needs different commands, though the
behaviour of TAB is unusual -- successive use cycles between the valid
indentations for a line (like in Haskell mode).

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: python-mode: keep mark when shifting [patch]
@ 2006-03-12 13:02 Dave Love
  0 siblings, 0 replies; 9+ messages in thread
From: Dave Love @ 2006-03-12 13:02 UTC (permalink / raw)
  Cc: Henrik Enberg, Emacs-Devel '

David Reitter <david.reitter@gmail.com> writes:

> The ideal situation in my view would be a default indent command
> which is modified by the major mode if necessary. That way, I
> wouldn't have to learn different key bindings for indent commands for
> programming in Perl and Python.

What command for you mean for Perl?  I can't see anything equivalent.

Whatever, it would be best to fix the bugs first.

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: python-mode: keep mark when shifting [patch]
@ 2006-03-10 15:17 Dave Love
  0 siblings, 0 replies; 9+ messages in thread
From: Dave Love @ 2006-03-10 15:17 UTC (permalink / raw)
  Cc: Emacs-Devel

David Reitter <david.reitter@gmail.com> writes:

> The patch below fixed a behavior of python-mode that I've found
> somewhat annoying: it deactivates the mark whenever you do C-c < or C-
> c > to shift a block to the left or right. Because one commonly needs
> to do this several times in a row (checking visually in between),
> it's very unhelpful if the mark gets deactivated.

I don't have an opinion on the behaviour, and it probably wouldn't be
relevant anyway, but if anything changes it should be
`indent-rigidly', which python-shift-... uses.

^ permalink raw reply	[flat|nested] 9+ messages in thread
* python-mode: keep mark when shifting [patch]
@ 2006-03-09 18:31 David Reitter
  2006-03-10 20:40 ` Henrik Enberg
  0 siblings, 1 reply; 9+ messages in thread
From: David Reitter @ 2006-03-09 18:31 UTC (permalink / raw)
  Cc: Emacs-Devel '

The patch below fixed a behavior of python-mode that I've found  
somewhat annoying: it deactivates the mark whenever you do C-c < or C- 
c > to shift a block to the left or right. Because one commonly needs  
to do this several times in a row (checking visually in between),  
it's very unhelpful if the mark gets deactivated.

Secondly, I was wondering if there is / could be a convention for  
shifting code horizontally.


*** python.el	22 Feb 2006 19:15:41 +0000	1.36
--- python.el	09 Mar 2006 18:24:05 +0000	
***************
*** 1532,1544 ****
       (setq count python-indent))
     (when (> count 0)
       (save-excursion
         (goto-char start)
         (while (< (point) end)
   	(if (and (< (current-indentation) count)
   		 (not (looking-at "[ \t]*$")))
   	    (error "Can't shift all lines enough"))
   	(forward-line))
!       (indent-rigidly start end (- count)))))

   (add-to-list 'debug-ignored-errors "^Can't shift all lines enough")

--- 1532,1545 ----
       (setq count python-indent))
     (when (> count 0)
       (save-excursion
+       (let ((deactivate-mark))
         (goto-char start)
         (while (< (point) end)
   	(if (and (< (current-indentation) count)
   		 (not (looking-at "[ \t]*$")))
   	    (error "Can't shift all lines enough"))
   	(forward-line))
!       (indent-rigidly start end (- count))))))

   (add-to-list 'debug-ignored-errors "^Can't shift all lines enough")

***************
*** 1553,1559 ****
     (if count
         (setq count (prefix-numeric-value count))
       (setq count python-indent))
!   (indent-rigidly start end count))

   (defun python-outline-level ()
     "`outline-level' function for Python mode.
--- 1554,1562 ----
     (if count
         (setq count (prefix-numeric-value count))
       (setq count python-indent))
!
!   (let ((deactivate-mark))
!     (indent-rigidly start end count)))

   (defun python-outline-level ()
     "`outline-level' function for Python mode.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-03-13 22:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-13  0:22 python-mode: keep mark when shifting [patch] Dave Love
2006-03-13 11:34 ` David Reitter
2006-03-13 22:42   ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2006-03-12 13:02 Dave Love
2006-03-10 15:17 Dave Love
2006-03-09 18:31 David Reitter
2006-03-10 20:40 ` Henrik Enberg
2006-03-11 17:12   ` David Reitter
2006-03-12 12:47     ` 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.