diff options
| -rw-r--r-- | lisp/simple.el | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index e12c520e5ca..8f3ab1d61f2 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -274,13 +274,13 @@ column specified by the function `current-left-margin'." | |||
| 274 | (defun kill-forward-chars (arg) | 274 | (defun kill-forward-chars (arg) |
| 275 | (if (listp arg) (setq arg (car arg))) | 275 | (if (listp arg) (setq arg (car arg))) |
| 276 | (if (eq arg '-) (setq arg -1)) | 276 | (if (eq arg '-) (setq arg -1)) |
| 277 | (kill-region (point) (+ (point) arg))) | 277 | (kill-region (point) (forward-point arg))) |
| 278 | 278 | ||
| 279 | ;; Internal subroutine of backward-delete-char | 279 | ;; Internal subroutine of backward-delete-char |
| 280 | (defun kill-backward-chars (arg) | 280 | (defun kill-backward-chars (arg) |
| 281 | (if (listp arg) (setq arg (car arg))) | 281 | (if (listp arg) (setq arg (car arg))) |
| 282 | (if (eq arg '-) (setq arg -1)) | 282 | (if (eq arg '-) (setq arg -1)) |
| 283 | (kill-region (point) (- (point) arg))) | 283 | (kill-region (point) (forward-point (- arg)))) |
| 284 | 284 | ||
| 285 | (defun backward-delete-char-untabify (arg &optional killp) | 285 | (defun backward-delete-char-untabify (arg &optional killp) |
| 286 | "Delete characters backward, changing tabs into spaces. | 286 | "Delete characters backward, changing tabs into spaces. |
| @@ -424,9 +424,10 @@ and the greater of them is not at the start of a line." | |||
| 424 | done))) | 424 | done))) |
| 425 | (- (buffer-size) (forward-line (buffer-size))))))) | 425 | (- (buffer-size) (forward-line (buffer-size))))))) |
| 426 | 426 | ||
| 427 | (defun what-cursor-position () | 427 | (defun what-cursor-position (&optional detail) |
| 428 | "Print info on cursor position (on screen and within buffer)." | 428 | "Print info on cursor position (on screen and within buffer). |
| 429 | (interactive) | 429 | With prefix argument, print detailed info of a character on cursor position." |
| 430 | (interactive "P") | ||
| 430 | (let* ((char (following-char)) | 431 | (let* ((char (following-char)) |
| 431 | (beg (point-min)) | 432 | (beg (point-min)) |
| 432 | (end (point-max)) | 433 | (end (point-max)) |
| @@ -446,11 +447,18 @@ and the greater of them is not at the start of a line." | |||
| 446 | pos total percent beg end col hscroll) | 447 | pos total percent beg end col hscroll) |
| 447 | (message "point=%d of %d(%d%%) column %d %s" | 448 | (message "point=%d of %d(%d%%) column %d %s" |
| 448 | pos total percent col hscroll)) | 449 | pos total percent col hscroll)) |
| 449 | (if (or (/= beg 1) (/= end (1+ total))) | 450 | (let ((str (if detail (format " %s" (split-char char)) ""))) |
| 450 | (message "Char: %s (0%o, %d, 0x%x) point=%d of %d(%d%%) <%d - %d> column %d %s" | 451 | (if (or (/= beg 1) (/= end (1+ total))) |
| 451 | (single-key-description char) char char char pos total percent beg end col hscroll) | 452 | (message "Char: %s (0%o, %d, 0x%x) %s point=%d of %d(%d%%) <%d - %d> column %d %s" |
| 452 | (message "Char: %s (0%o, %d, 0x%x) point=%d of %d(%d%%) column %d %s" | 453 | (if (< char 256) |
| 453 | (single-key-description char) char char char pos total percent col hscroll))))) | 454 | (single-key-description char) |
| 455 | (char-to-string char)) | ||
| 456 | char char char str pos total percent beg end col hscroll) | ||
| 457 | (message "Char: %s (0%o, %d, 0x%x)%s point=%d of %d(%d%%) column %d %s" | ||
| 458 | (if (< char 256) | ||
| 459 | (single-key-description char) | ||
| 460 | (char-to-string char)) | ||
| 461 | char char char str pos total percent col hscroll)))))) | ||
| 454 | 462 | ||
| 455 | (defun fundamental-mode () | 463 | (defun fundamental-mode () |
| 456 | "Major mode not specialized for anything in particular. | 464 | "Major mode not specialized for anything in particular. |
| @@ -2063,14 +2071,16 @@ With argument 0, interchanges line point is in with line mark is in." | |||
| 2063 | (defun transpose-subr-1 () | 2071 | (defun transpose-subr-1 () |
| 2064 | (if (> (min end1 end2) (max start1 start2)) | 2072 | (if (> (min end1 end2) (max start1 start2)) |
| 2065 | (error "Don't have two things to transpose")) | 2073 | (error "Don't have two things to transpose")) |
| 2066 | (let ((word1 (buffer-substring start1 end1)) | 2074 | (let* ((word1 (buffer-substring start1 end1)) |
| 2067 | (word2 (buffer-substring start2 end2))) | 2075 | (len1 (length word1)) |
| 2076 | (word2 (buffer-substring start2 end2)) | ||
| 2077 | (len2 (length word2))) | ||
| 2068 | (delete-region start2 end2) | 2078 | (delete-region start2 end2) |
| 2069 | (goto-char start2) | 2079 | (goto-char start2) |
| 2070 | (insert word1) | 2080 | (insert word1) |
| 2071 | (goto-char (if (< start1 start2) start1 | 2081 | (goto-char (if (< start1 start2) start1 |
| 2072 | (+ start1 (- (length word1) (length word2))))) | 2082 | (+ start1 (- len1 len2)))) |
| 2073 | (delete-char (length word1)) | 2083 | (delete-region (point) (+ (point) len1)) |
| 2074 | (insert word2))) | 2084 | (insert word2))) |
| 2075 | 2085 | ||
| 2076 | (defvar comment-column 32 | 2086 | (defvar comment-column 32 |
| @@ -2403,7 +2413,12 @@ Setting this variable automatically makes it local to the current buffer.") | |||
| 2403 | (looking-at (regexp-quote fill-prefix)) | 2413 | (looking-at (regexp-quote fill-prefix)) |
| 2404 | (setq after-prefix (match-end 0))) | 2414 | (setq after-prefix (match-end 0))) |
| 2405 | (move-to-column (1+ fc)) | 2415 | (move-to-column (1+ fc)) |
| 2406 | ;; Move back to a word boundary. | 2416 | ;; Move back to the point where we can break the |
| 2417 | ;; line at. We break the line between word or | ||
| 2418 | ;; after/before the character which has character | ||
| 2419 | ;; category `|'. We search space, \c| followed by | ||
| 2420 | ;; a character, or \c| follwoing a character. If | ||
| 2421 | ;; not found, place the point at beginning of line. | ||
| 2407 | (while (or first | 2422 | (while (or first |
| 2408 | ;; If this is after period and a single space, | 2423 | ;; If this is after period and a single space, |
| 2409 | ;; move back once more--we don't want to break | 2424 | ;; move back once more--we don't want to break |
| @@ -2416,15 +2431,22 @@ Setting this variable automatically makes it local to the current buffer.") | |||
| 2416 | (and (looking-at "\\. ") | 2431 | (and (looking-at "\\. ") |
| 2417 | (not (looking-at "\\. ")))))) | 2432 | (not (looking-at "\\. ")))))) |
| 2418 | (setq first nil) | 2433 | (setq first nil) |
| 2419 | (skip-chars-backward "^ \t\n") | 2434 | (re-search-backward "[ \t]\\|\\c|.\\|.\\c|\\|^") |
| 2420 | ;; If we find nowhere on the line to break it, | 2435 | ;; If we find nowhere on the line to break it, |
| 2421 | ;; break after one word. Set bounce to t | 2436 | ;; break after one word. Set bounce to t |
| 2422 | ;; so we will not keep going in this while loop. | 2437 | ;; so we will not keep going in this while loop. |
| 2423 | (if (<= (point) after-prefix) | 2438 | (if (<= (point) after-prefix) |
| 2424 | (progn | 2439 | (progn |
| 2425 | (re-search-forward "[ \t]" opoint t) | 2440 | (re-search-forward "[ \t]" opoint t) |
| 2426 | (setq bounce t))) | 2441 | (setq bounce t)) |
| 2427 | (skip-chars-backward " \t")) | 2442 | (if (looking-at "[ \t]") |
| 2443 | ;; Break the line at word boundary. | ||
| 2444 | (skip-chars-backward " \t") | ||
| 2445 | ;; Break the line after/before \c|. | ||
| 2446 | (forward-char 1) | ||
| 2447 | (if do-kinsoku | ||
| 2448 | (kinsoku (save-excursion | ||
| 2449 | (forward-line 0) (point))))))) | ||
| 2428 | ;; Let fill-point be set to the place where we end up. | 2450 | ;; Let fill-point be set to the place where we end up. |
| 2429 | (point))))) | 2451 | (point))))) |
| 2430 | ;; If that place is not the beginning of the line, | 2452 | ;; If that place is not the beginning of the line, |