Python mode - `C-c |' feature suggestion
Alex
alex at somewhere.round.here
Tue Feb 22 12:14:42 EST 2000
More information about the Python-list mailing list
Tue Feb 22 12:14:42 EST 2000
- Previous message (by thread): Python mode - `C-c |' feature suggestion
- Next message (by thread): Python mode - `C-c |' feature suggestion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> >>>>> "I" == ISO <pinard at iro.umontreal.ca> writes: > > I> My suggestion is that `C-c |' be made clever enough to discover > I> the left margin of the region under consideration, and that it > I> removes that margin while transmitting the region to the Python > I> interpreter. That would allow for using that command in a much > I> wider variety of (smaller :-) contexts. > > I've also wanted this for a while, but never had the time to add it. > I'd accept a patch that implemented this feature. This is very cursorily tested, but it seems to do the job. I'll post again if I find any flaws (I will probably use it a lot, too.) By the way, what are all the control-L's for? Alex. pot% diff --context python-mode.el python-mode.el.1 *** python-mode.el Tue Feb 22 12:04:13 2000 --- python-mode.el.1 Fri Aug 13 11:59:54 1999 *************** *** 1239,1255 **** (setq py-file-queue nil) (message "%d pending files de-queued." n))) - - (defun py-remove-common-indentation () - ;; py-region-shift-* (start end) doesn't move the line end is on, so - ;; add a newline to the end of the file for end to refer to. - (goto-char (point-max)) - (insert "\n") - (while (progn - (goto-char (point-min)) - (not (re-search-forward "^\\S-" nil t))) - (py-shift-region-left (point-min) (point-max)))) - (defun py-execute-region (start end &optional async) "Execute the region in a Python interpreter. --- 1239,1244 ---- *************** *** 1289,1300 **** (format "python-%d-%d" sn pid) (format "python-%d" sn))) (make-temp-name "python-"))) ! (file (expand-file-name temp py-temp-directory)) ! (code-for-execution (buffer-substring-no-properties start end))) ! (set-buffer (get-buffer-create file)) ! (insert code-for-execution) ! (py-remove-common-indentation) ! (write-region (point-min) (point-max) file nil 'nomsg) (cond ;; always run the code in its own asynchronous subprocess (async --- 1278,1285 ---- (format "python-%d-%d" sn pid) (format "python-%d" sn))) (make-temp-name "python-"))) ! (file (expand-file-name temp py-temp-directory))) ! (write-region start end file nil 'nomsg) (cond ;; always run the code in its own asynchronous subprocess (async
- Previous message (by thread): Python mode - `C-c |' feature suggestion
- Next message (by thread): Python mode - `C-c |' feature suggestion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list