comparison lisp/emulation/pc-select.el @ 86157:a54bf760b43d

(pc-select-shifted-mark): Remove. (pc-select-ensure-mark): Set mark-active to a special value instead. Rename from ensure-mark. Update call callers. (pc-select-maybe-deactivate-mark): Rename from maybe-deactivate-mark. Rewrite. Update all callers. (pc-selection-mode): Remove redundant var declaration.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 16 Nov 2007 18:07:14 +0000
parents 39b88001b04b
children 107ccd98fa12 53108e6cea98
comparison
equal deleted inserted replaced
86156:d98fdcca854b 86157:a54bf760b43d
252 "Holds the old mapping of [M-delete] in the `function-key-map'. 252 "Holds the old mapping of [M-delete] in the `function-key-map'.
253 This variable holds the value associated with [M-delete] in the 253 This variable holds the value associated with [M-delete] in the
254 `function-key-map' before PC Selection mode had changed that 254 `function-key-map' before PC Selection mode had changed that
255 association.") 255 association.")
256 256
257 (defvar pc-select-shifted-mark nil
258 "Holds whether we ourselves did activate the mark. Only then
259 should we deactivate if later on.")
260
261 ;;;; 257 ;;;;
262 ;; misc 258 ;; misc
263 ;;;; 259 ;;;;
264 260
265 (provide 'pc-select) 261 (provide 'pc-select)
283 (setq mark-active nil)) 279 (setq mark-active nil))
284 280
285 ;;;; 281 ;;;;
286 ;; non-interactive 282 ;; non-interactive
287 ;;;; 283 ;;;;
288 (defun ensure-mark() 284 (defun pc-select-ensure-mark ()
289 ;; make sure mark is active 285 ;; make sure mark is active
290 ;; test if it is active, if it isn't, set it and activate it 286 ;; test if it is active, if it isn't, set it and activate it
291 (or mark-active (set-mark-command nil)) 287 (or mark-active (set-mark-command nil))
292 (setq pc-select-shifted-mark t)) 288 ;; Remember who activated the mark.
293 289 (setq mark-active 'pc-select))
294 (defun maybe-deactivate-mark() 290
291 (defun pc-select-maybe-deactivate-mark ()
295 ;; maybe switch off mark (only if *we* switched it on) 292 ;; maybe switch off mark (only if *we* switched it on)
296 (if pc-select-shifted-mark 293 (when (eq mark-active 'pc-select)
297 (progn 294 (deactivate-mark)))
298 (setq mark-active nil)
299 (setq pc-select-shifted-mark nil))))
300 295
301 ;;;;;;;;;;;;;;;;;;;;;;;;;;; 296 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
302 ;;;;; forward and mark 297 ;;;;; forward and mark
303 ;;;;;;;;;;;;;;;;;;;;;;;;;;; 298 ;;;;;;;;;;;;;;;;;;;;;;;;;;;
304 299
305 (defun forward-char-mark (&optional arg) 300 (defun forward-char-mark (&optional arg)
306 "Ensure mark is active; move point right ARG characters (left if ARG negative). 301 "Ensure mark is active; move point right ARG characters (left if ARG negative).
307 On reaching end of buffer, stop and signal error." 302 On reaching end of buffer, stop and signal error."
308 (interactive "p") 303 (interactive "p")
309 (ensure-mark) 304 (pc-select-ensure-mark)
310 (forward-char arg)) 305 (forward-char arg))
311 306
312 (defun forward-word-mark (&optional arg) 307 (defun forward-word-mark (&optional arg)
313 "Ensure mark is active; move point right ARG words (backward if ARG is negative). 308 "Ensure mark is active; move point right ARG words (backward if ARG is negative).
314 Normally returns t. 309 Normally returns t.
315 If an edge of the buffer is reached, point is left there 310 If an edge of the buffer is reached, point is left there
316 and nil is returned." 311 and nil is returned."
317 (interactive "p") 312 (interactive "p")
318 (ensure-mark) 313 (pc-select-ensure-mark)
319 (forward-word arg)) 314 (forward-word arg))
320 315
321 (defun forward-line-mark (&optional arg) 316 (defun forward-line-mark (&optional arg)
322 "Ensure mark is active; move cursor vertically down ARG lines." 317 "Ensure mark is active; move cursor vertically down ARG lines."
323 (interactive "p") 318 (interactive "p")
324 (ensure-mark) 319 (pc-select-ensure-mark)
325 (forward-line arg) 320 (forward-line arg)
326 (setq this-command 'forward-line) 321 (setq this-command 'forward-line)
327 ) 322 )
328 323
329 (defun forward-sexp-mark (&optional arg) 324 (defun forward-sexp-mark (&optional arg)
330 "Ensure mark is active; move forward across one balanced expression (sexp). 325 "Ensure mark is active; move forward across one balanced expression (sexp).
331 With argument, do it that many times. Negative arg -N means 326 With argument, do it that many times. Negative arg -N means
332 move backward across N balanced expressions." 327 move backward across N balanced expressions."
333 (interactive "p") 328 (interactive "p")
334 (ensure-mark) 329 (pc-select-ensure-mark)
335 (forward-sexp arg)) 330 (forward-sexp arg))
336 331
337 (defun forward-paragraph-mark (&optional arg) 332 (defun forward-paragraph-mark (&optional arg)
338 "Ensure mark is active; move forward to end of paragraph. 333 "Ensure mark is active; move forward to end of paragraph.
339 With arg N, do it N times; negative arg -N means move backward N paragraphs. 334 With arg N, do it N times; negative arg -N means move backward N paragraphs.
341 A line which `paragraph-start' matches either separates paragraphs 336 A line which `paragraph-start' matches either separates paragraphs
342 \(if `paragraph-separate' matches it also) or is the first line of a paragraph. 337 \(if `paragraph-separate' matches it also) or is the first line of a paragraph.
343 A paragraph end is the beginning of a line which is not part of the paragraph 338 A paragraph end is the beginning of a line which is not part of the paragraph
344 to which the end of the previous line belongs, or the end of the buffer." 339 to which the end of the previous line belongs, or the end of the buffer."
345 (interactive "p") 340 (interactive "p")
346 (ensure-mark) 341 (pc-select-ensure-mark)
347 (forward-paragraph arg)) 342 (forward-paragraph arg))
348 343
349 (defun next-line-mark (&optional arg) 344 (defun next-line-mark (&optional arg)
350 "Ensure mark is active; move cursor vertically down ARG lines. 345 "Ensure mark is active; move cursor vertically down ARG lines.
351 If there is no character in the target line exactly under the current column, 346 If there is no character in the target line exactly under the current column,
360 The command \\[set-goal-column] can be used to create 355 The command \\[set-goal-column] can be used to create
361 a semipermanent goal column to which this command always moves. 356 a semipermanent goal column to which this command always moves.
362 Then it does not try to move vertically. This goal column is stored 357 Then it does not try to move vertically. This goal column is stored
363 in `goal-column', which is nil when there is none." 358 in `goal-column', which is nil when there is none."
364 (interactive "p") 359 (interactive "p")
365 (ensure-mark) 360 (pc-select-ensure-mark)
366 (with-no-warnings (next-line arg)) 361 (with-no-warnings (next-line arg))
367 (setq this-command 'next-line)) 362 (setq this-command 'next-line))
368 363
369 (defun end-of-line-mark (&optional arg) 364 (defun end-of-line-mark (&optional arg)
370 "Ensure mark is active; move point to end of current line. 365 "Ensure mark is active; move point to end of current line.
371 With argument ARG not nil or 1, move forward ARG - 1 lines first. 366 With argument ARG not nil or 1, move forward ARG - 1 lines first.
372 If scan reaches end of buffer, stop there without error." 367 If scan reaches end of buffer, stop there without error."
373 (interactive "p") 368 (interactive "p")
374 (ensure-mark) 369 (pc-select-ensure-mark)
375 (end-of-line arg) 370 (end-of-line arg)
376 (setq this-command 'end-of-line)) 371 (setq this-command 'end-of-line))
377 372
378 (defun backward-line-mark (&optional arg) 373 (defun backward-line-mark (&optional arg)
379 "Ensure mark is active; move cursor vertically up ARG lines." 374 "Ensure mark is active; move cursor vertically up ARG lines."
380 (interactive "p") 375 (interactive "p")
381 (ensure-mark) 376 (pc-select-ensure-mark)
382 (if (null arg) 377 (if (null arg)
383 (setq arg 1)) 378 (setq arg 1))
384 (forward-line (- arg)) 379 (forward-line (- arg))
385 (setq this-command 'forward-line) 380 (setq this-command 'forward-line)
386 ) 381 )
389 "Ensure mark is active; scroll down ARG lines; or near full screen if no ARG. 384 "Ensure mark is active; scroll down ARG lines; or near full screen if no ARG.
390 A near full screen is `next-screen-context-lines' less than a full screen. 385 A near full screen is `next-screen-context-lines' less than a full screen.
391 Negative ARG means scroll upward. 386 Negative ARG means scroll upward.
392 When calling from a program, supply a number as argument or nil." 387 When calling from a program, supply a number as argument or nil."
393 (interactive "P") 388 (interactive "P")
394 (ensure-mark) 389 (pc-select-ensure-mark)
395 (cond (pc-select-override-scroll-error 390 (cond (pc-select-override-scroll-error
396 (condition-case nil (scroll-down arg) 391 (condition-case nil (scroll-down arg)
397 (beginning-of-buffer (goto-char (point-min))))) 392 (beginning-of-buffer (goto-char (point-min)))))
398 (t (scroll-down arg)))) 393 (t (scroll-down arg))))
399 394
405 of the accessible part of the buffer. 400 of the accessible part of the buffer.
406 401
407 Don't use this command in Lisp programs! 402 Don't use this command in Lisp programs!
408 \(goto-char \(point-max)) is faster and avoids clobbering the mark." 403 \(goto-char \(point-max)) is faster and avoids clobbering the mark."
409 (interactive "P") 404 (interactive "P")
410 (ensure-mark) 405 (pc-select-ensure-mark)
411 (let ((size (- (point-max) (point-min)))) 406 (let ((size (- (point-max) (point-min))))
412 (goto-char (if arg 407 (goto-char (if arg
413 (- (point-max) 408 (- (point-max)
414 (if (> size 10000) 409 (if (> size 10000)
415 ;; Avoid overflow for large buffer sizes! 410 ;; Avoid overflow for large buffer sizes!
437 432
438 (defun forward-char-nomark (&optional arg) 433 (defun forward-char-nomark (&optional arg)
439 "Deactivate mark; move point right ARG characters \(left if ARG negative). 434 "Deactivate mark; move point right ARG characters \(left if ARG negative).
440 On reaching end of buffer, stop and signal error." 435 On reaching end of buffer, stop and signal error."
441 (interactive "p") 436 (interactive "p")
442 (maybe-deactivate-mark) 437 (pc-select-maybe-deactivate-mark)
443 (forward-char arg)) 438 (forward-char arg))
444 439
445 (defun forward-word-nomark (&optional arg) 440 (defun forward-word-nomark (&optional arg)
446 "Deactivate mark; move point right ARG words \(backward if ARG is negative). 441 "Deactivate mark; move point right ARG words \(backward if ARG is negative).
447 Normally returns t. 442 Normally returns t.
448 If an edge of the buffer is reached, point is left there 443 If an edge of the buffer is reached, point is left there
449 and nil is returned." 444 and nil is returned."
450 (interactive "p") 445 (interactive "p")
451 (maybe-deactivate-mark) 446 (pc-select-maybe-deactivate-mark)
452 (forward-word arg)) 447 (forward-word arg))
453 448
454 (defun forward-line-nomark (&optional arg) 449 (defun forward-line-nomark (&optional arg)
455 "Deactivate mark; move cursor vertically down ARG lines." 450 "Deactivate mark; move cursor vertically down ARG lines."
456 (interactive "p") 451 (interactive "p")
457 (maybe-deactivate-mark) 452 (pc-select-maybe-deactivate-mark)
458 (forward-line arg) 453 (forward-line arg)
459 (setq this-command 'forward-line) 454 (setq this-command 'forward-line)
460 ) 455 )
461 456
462 (defun forward-sexp-nomark (&optional arg) 457 (defun forward-sexp-nomark (&optional arg)
463 "Deactivate mark; move forward across one balanced expression (sexp). 458 "Deactivate mark; move forward across one balanced expression (sexp).
464 With argument, do it that many times. Negative arg -N means 459 With argument, do it that many times. Negative arg -N means
465 move backward across N balanced expressions." 460 move backward across N balanced expressions."
466 (interactive "p") 461 (interactive "p")
467 (maybe-deactivate-mark) 462 (pc-select-maybe-deactivate-mark)
468 (forward-sexp arg)) 463 (forward-sexp arg))
469 464
470 (defun forward-paragraph-nomark (&optional arg) 465 (defun forward-paragraph-nomark (&optional arg)
471 "Deactivate mark; move forward to end of paragraph. 466 "Deactivate mark; move forward to end of paragraph.
472 With arg N, do it N times; negative arg -N means move backward N paragraphs. 467 With arg N, do it N times; negative arg -N means move backward N paragraphs.
474 A line which `paragraph-start' matches either separates paragraphs 469 A line which `paragraph-start' matches either separates paragraphs
475 \(if `paragraph-separate' matches it also) or is the first line of a paragraph. 470 \(if `paragraph-separate' matches it also) or is the first line of a paragraph.
476 A paragraph end is the beginning of a line which is not part of the paragraph 471 A paragraph end is the beginning of a line which is not part of the paragraph
477 to which the end of the previous line belongs, or the end of the buffer." 472 to which the end of the previous line belongs, or the end of the buffer."
478 (interactive "p") 473 (interactive "p")
479 (maybe-deactivate-mark) 474 (pc-select-maybe-deactivate-mark)
480 (forward-paragraph arg)) 475 (forward-paragraph arg))
481 476
482 (defun next-line-nomark (&optional arg) 477 (defun next-line-nomark (&optional arg)
483 "Deactivate mark; move cursor vertically down ARG lines. 478 "Deactivate mark; move cursor vertically down ARG lines.
484 If there is no character in the target line exactly under the current column, 479 If there is no character in the target line exactly under the current column,
493 The command \\[set-goal-column] can be used to create 488 The command \\[set-goal-column] can be used to create
494 a semipermanent goal column to which this command always moves. 489 a semipermanent goal column to which this command always moves.
495 Then it does not try to move vertically. This goal column is stored 490 Then it does not try to move vertically. This goal column is stored
496 in `goal-column', which is nil when there is none." 491 in `goal-column', which is nil when there is none."
497 (interactive "p") 492 (interactive "p")
498 (maybe-deactivate-mark) 493 (pc-select-maybe-deactivate-mark)
499 (with-no-warnings (next-line arg)) 494 (with-no-warnings (next-line arg))
500 (setq this-command 'next-line)) 495 (setq this-command 'next-line))
501 496
502 (defun end-of-line-nomark (&optional arg) 497 (defun end-of-line-nomark (&optional arg)
503 "Deactivate mark; move point to end of current line. 498 "Deactivate mark; move point to end of current line.
504 With argument ARG not nil or 1, move forward ARG - 1 lines first. 499 With argument ARG not nil or 1, move forward ARG - 1 lines first.
505 If scan reaches end of buffer, stop there without error." 500 If scan reaches end of buffer, stop there without error."
506 (interactive "p") 501 (interactive "p")
507 (maybe-deactivate-mark) 502 (pc-select-maybe-deactivate-mark)
508 (end-of-line arg) 503 (end-of-line arg)
509 (setq this-command 'end-of-line)) 504 (setq this-command 'end-of-line))
510 505
511 (defun backward-line-nomark (&optional arg) 506 (defun backward-line-nomark (&optional arg)
512 "Deactivate mark; move cursor vertically up ARG lines." 507 "Deactivate mark; move cursor vertically up ARG lines."
513 (interactive "p") 508 (interactive "p")
514 (maybe-deactivate-mark) 509 (pc-select-maybe-deactivate-mark)
515 (if (null arg) 510 (if (null arg)
516 (setq arg 1)) 511 (setq arg 1))
517 (forward-line (- arg)) 512 (forward-line (- arg))
518 (setq this-command 'forward-line) 513 (setq this-command 'forward-line)
519 ) 514 )
522 "Deactivate mark; scroll down ARG lines; or near full screen if no ARG. 517 "Deactivate mark; scroll down ARG lines; or near full screen if no ARG.
523 A near full screen is `next-screen-context-lines' less than a full screen. 518 A near full screen is `next-screen-context-lines' less than a full screen.
524 Negative ARG means scroll upward. 519 Negative ARG means scroll upward.
525 When calling from a program, supply a number as argument or nil." 520 When calling from a program, supply a number as argument or nil."
526 (interactive "P") 521 (interactive "P")
527 (maybe-deactivate-mark) 522 (pc-select-maybe-deactivate-mark)
528 (cond (pc-select-override-scroll-error 523 (cond (pc-select-override-scroll-error
529 (condition-case nil (scroll-down arg) 524 (condition-case nil (scroll-down arg)
530 (beginning-of-buffer (goto-char (point-min))))) 525 (beginning-of-buffer (goto-char (point-min)))))
531 (t (scroll-down arg)))) 526 (t (scroll-down arg))))
532 527
538 of the accessible part of the buffer. 533 of the accessible part of the buffer.
539 534
540 Don't use this command in Lisp programs! 535 Don't use this command in Lisp programs!
541 \(goto-char (point-max)) is faster and avoids clobbering the mark." 536 \(goto-char (point-max)) is faster and avoids clobbering the mark."
542 (interactive "P") 537 (interactive "P")
543 (maybe-deactivate-mark) 538 (pc-select-maybe-deactivate-mark)
544 (let ((size (- (point-max) (point-min)))) 539 (let ((size (- (point-max) (point-min))))
545 (goto-char (if arg 540 (goto-char (if arg
546 (- (point-max) 541 (- (point-max)
547 (if (> size 10000) 542 (if (> size 10000)
548 ;; Avoid overflow for large buffer sizes! 543 ;; Avoid overflow for large buffer sizes!
571 566
572 (defun backward-char-mark (&optional arg) 567 (defun backward-char-mark (&optional arg)
573 "Ensure mark is active; move point left ARG characters (right if ARG negative). 568 "Ensure mark is active; move point left ARG characters (right if ARG negative).
574 On attempt to pass beginning or end of buffer, stop and signal error." 569 On attempt to pass beginning or end of buffer, stop and signal error."
575 (interactive "p") 570 (interactive "p")
576 (ensure-mark) 571 (pc-select-ensure-mark)
577 (backward-char arg)) 572 (backward-char arg))
578 573
579 (defun backward-word-mark (&optional arg) 574 (defun backward-word-mark (&optional arg)
580 "Ensure mark is active; move backward until encountering the end of a word. 575 "Ensure mark is active; move backward until encountering the end of a word.
581 With argument, do this that many times." 576 With argument, do this that many times."
582 (interactive "p") 577 (interactive "p")
583 (ensure-mark) 578 (pc-select-ensure-mark)
584 (backward-word arg)) 579 (backward-word arg))
585 580
586 (defun backward-sexp-mark (&optional arg) 581 (defun backward-sexp-mark (&optional arg)
587 "Ensure mark is active; move backward across one balanced expression (sexp). 582 "Ensure mark is active; move backward across one balanced expression (sexp).
588 With argument, do it that many times. Negative arg -N means 583 With argument, do it that many times. Negative arg -N means
589 move forward across N balanced expressions." 584 move forward across N balanced expressions."
590 (interactive "p") 585 (interactive "p")
591 (ensure-mark) 586 (pc-select-ensure-mark)
592 (backward-sexp arg)) 587 (backward-sexp arg))
593 588
594 (defun backward-paragraph-mark (&optional arg) 589 (defun backward-paragraph-mark (&optional arg)
595 "Ensure mark is active; move backward to start of paragraph. 590 "Ensure mark is active; move backward to start of paragraph.
596 With arg N, do it N times; negative arg -N means move forward N paragraphs. 591 With arg N, do it N times; negative arg -N means move forward N paragraphs.
601 paragraph is preceded by a blank line, the paragraph starts at that 596 paragraph is preceded by a blank line, the paragraph starts at that
602 blank line. 597 blank line.
603 598
604 See `forward-paragraph' for more information." 599 See `forward-paragraph' for more information."
605 (interactive "p") 600 (interactive "p")
606 (ensure-mark) 601 (pc-select-ensure-mark)
607 (backward-paragraph arg)) 602 (backward-paragraph arg))
608 603
609 (defun previous-line-mark (&optional arg) 604 (defun previous-line-mark (&optional arg)
610 "Ensure mark is active; move cursor vertically up ARG lines. 605 "Ensure mark is active; move cursor vertically up ARG lines.
611 If there is no character in the target line exactly over the current column, 606 If there is no character in the target line exactly over the current column,
618 613
619 If you are thinking of using this in a Lisp program, consider using 614 If you are thinking of using this in a Lisp program, consider using
620 `forward-line' with a negative argument instead. It is usually easier 615 `forward-line' with a negative argument instead. It is usually easier
621 to use and more reliable (no dependence on goal column, etc.)." 616 to use and more reliable (no dependence on goal column, etc.)."
622 (interactive "p") 617 (interactive "p")
623 (ensure-mark) 618 (pc-select-ensure-mark)
624 (with-no-warnings (previous-line arg)) 619 (with-no-warnings (previous-line arg))
625 (setq this-command 'previous-line)) 620 (setq this-command 'previous-line))
626 621
627 (defun beginning-of-line-mark (&optional arg) 622 (defun beginning-of-line-mark (&optional arg)
628 "Ensure mark is active; move point to beginning of current line. 623 "Ensure mark is active; move point to beginning of current line.
629 With argument ARG not nil or 1, move forward ARG - 1 lines first. 624 With argument ARG not nil or 1, move forward ARG - 1 lines first.
630 If scan reaches end of buffer, stop there without error." 625 If scan reaches end of buffer, stop there without error."
631 (interactive "p") 626 (interactive "p")
632 (ensure-mark) 627 (pc-select-ensure-mark)
633 (beginning-of-line arg)) 628 (beginning-of-line arg))
634 629
635 630
636 (defun scroll-up-mark (&optional arg) 631 (defun scroll-up-mark (&optional arg)
637 "Ensure mark is active; scroll upward ARG lines; or near full screen if no ARG. 632 "Ensure mark is active; scroll upward ARG lines; or near full screen if no ARG.
638 A near full screen is `next-screen-context-lines' less than a full screen. 633 A near full screen is `next-screen-context-lines' less than a full screen.
639 Negative ARG means scroll downward. 634 Negative ARG means scroll downward.
640 When calling from a program, supply a number as argument or nil." 635 When calling from a program, supply a number as argument or nil."
641 (interactive "P") 636 (interactive "P")
642 (ensure-mark) 637 (pc-select-ensure-mark)
643 (cond (pc-select-override-scroll-error 638 (cond (pc-select-override-scroll-error
644 (condition-case nil (scroll-up arg) 639 (condition-case nil (scroll-up arg)
645 (end-of-buffer (goto-char (point-max))))) 640 (end-of-buffer (goto-char (point-max)))))
646 (t (scroll-up arg)))) 641 (t (scroll-up arg))))
647 642
653 of the accessible part of the buffer. 648 of the accessible part of the buffer.
654 649
655 Don't use this command in Lisp programs! 650 Don't use this command in Lisp programs!
656 \(goto-char (p\oint-min)) is faster and avoids clobbering the mark." 651 \(goto-char (p\oint-min)) is faster and avoids clobbering the mark."
657 (interactive "P") 652 (interactive "P")
658 (ensure-mark) 653 (pc-select-ensure-mark)
659 (let ((size (- (point-max) (point-min)))) 654 (let ((size (- (point-max) (point-min))))
660 (goto-char (if arg 655 (goto-char (if arg
661 (+ (point-min) 656 (+ (point-min)
662 (if (> size 10000) 657 (if (> size 10000)
663 ;; Avoid overflow for large buffer sizes! 658 ;; Avoid overflow for large buffer sizes!
673 668
674 (defun backward-char-nomark (&optional arg) 669 (defun backward-char-nomark (&optional arg)
675 "Deactivate mark; move point left ARG characters (right if ARG negative). 670 "Deactivate mark; move point left ARG characters (right if ARG negative).
676 On attempt to pass beginning or end of buffer, stop and signal error." 671 On attempt to pass beginning or end of buffer, stop and signal error."
677 (interactive "p") 672 (interactive "p")
678 (maybe-deactivate-mark) 673 (pc-select-maybe-deactivate-mark)
679 (backward-char arg)) 674 (backward-char arg))
680 675
681 (defun backward-word-nomark (&optional arg) 676 (defun backward-word-nomark (&optional arg)
682 "Deactivate mark; move backward until encountering the end of a word. 677 "Deactivate mark; move backward until encountering the end of a word.
683 With argument, do this that many times." 678 With argument, do this that many times."
684 (interactive "p") 679 (interactive "p")
685 (maybe-deactivate-mark) 680 (pc-select-maybe-deactivate-mark)
686 (backward-word arg)) 681 (backward-word arg))
687 682
688 (defun backward-sexp-nomark (&optional arg) 683 (defun backward-sexp-nomark (&optional arg)
689 "Deactivate mark; move backward across one balanced expression (sexp). 684 "Deactivate mark; move backward across one balanced expression (sexp).
690 With argument, do it that many times. Negative arg -N means 685 With argument, do it that many times. Negative arg -N means
691 move forward across N balanced expressions." 686 move forward across N balanced expressions."
692 (interactive "p") 687 (interactive "p")
693 (maybe-deactivate-mark) 688 (pc-select-maybe-deactivate-mark)
694 (backward-sexp arg)) 689 (backward-sexp arg))
695 690
696 (defun backward-paragraph-nomark (&optional arg) 691 (defun backward-paragraph-nomark (&optional arg)
697 "Deactivate mark; move backward to start of paragraph. 692 "Deactivate mark; move backward to start of paragraph.
698 With arg N, do it N times; negative arg -N means move forward N paragraphs. 693 With arg N, do it N times; negative arg -N means move forward N paragraphs.
703 paragraph is preceded by a blank line, the paragraph starts at that 698 paragraph is preceded by a blank line, the paragraph starts at that
704 blank line. 699 blank line.
705 700
706 See `forward-paragraph' for more information." 701 See `forward-paragraph' for more information."
707 (interactive "p") 702 (interactive "p")
708 (maybe-deactivate-mark) 703 (pc-select-maybe-deactivate-mark)
709 (backward-paragraph arg)) 704 (backward-paragraph arg))
710 705
711 (defun previous-line-nomark (&optional arg) 706 (defun previous-line-nomark (&optional arg)
712 "Deactivate mark; move cursor vertically up ARG lines. 707 "Deactivate mark; move cursor vertically up ARG lines.
713 If there is no character in the target line exactly over the current column, 708 If there is no character in the target line exactly over the current column,
716 711
717 The command \\[set-goal-column] can be used to create 712 The command \\[set-goal-column] can be used to create
718 a semipermanent goal column to which this command always moves. 713 a semipermanent goal column to which this command always moves.
719 Then it does not try to move vertically." 714 Then it does not try to move vertically."
720 (interactive "p") 715 (interactive "p")
721 (maybe-deactivate-mark) 716 (pc-select-maybe-deactivate-mark)
722 (with-no-warnings (previous-line arg)) 717 (with-no-warnings (previous-line arg))
723 (setq this-command 'previous-line)) 718 (setq this-command 'previous-line))
724 719
725 (defun beginning-of-line-nomark (&optional arg) 720 (defun beginning-of-line-nomark (&optional arg)
726 "Deactivate mark; move point to beginning of current line. 721 "Deactivate mark; move point to beginning of current line.
727 With argument ARG not nil or 1, move forward ARG - 1 lines first. 722 With argument ARG not nil or 1, move forward ARG - 1 lines first.
728 If scan reaches end of buffer, stop there without error." 723 If scan reaches end of buffer, stop there without error."
729 (interactive "p") 724 (interactive "p")
730 (maybe-deactivate-mark) 725 (pc-select-maybe-deactivate-mark)
731 (beginning-of-line arg)) 726 (beginning-of-line arg))
732 727
733 (defun scroll-up-nomark (&optional arg) 728 (defun scroll-up-nomark (&optional arg)
734 "Deactivate mark; scroll upward ARG lines; or near full screen if no ARG. 729 "Deactivate mark; scroll upward ARG lines; or near full screen if no ARG.
735 A near full screen is `next-screen-context-lines' less than a full screen. 730 A near full screen is `next-screen-context-lines' less than a full screen.
736 Negative ARG means scroll downward. 731 Negative ARG means scroll downward.
737 When calling from a program, supply a number as argument or nil." 732 When calling from a program, supply a number as argument or nil."
738 (interactive "P") 733 (interactive "P")
739 (maybe-deactivate-mark) 734 (pc-select-maybe-deactivate-mark)
740 (cond (pc-select-override-scroll-error 735 (cond (pc-select-override-scroll-error
741 (condition-case nil (scroll-up arg) 736 (condition-case nil (scroll-up arg)
742 (end-of-buffer (goto-char (point-max))))) 737 (end-of-buffer (goto-char (point-max)))))
743 (t (scroll-up arg)))) 738 (t (scroll-up arg))))
744 739
750 of the accessible part of the buffer. 745 of the accessible part of the buffer.
751 746
752 Don't use this command in Lisp programs! 747 Don't use this command in Lisp programs!
753 \(goto-char (point-min)) is faster and avoids clobbering the mark." 748 \(goto-char (point-min)) is faster and avoids clobbering the mark."
754 (interactive "P") 749 (interactive "P")
755 (maybe-deactivate-mark) 750 (pc-select-maybe-deactivate-mark)
756 (let ((size (- (point-max) (point-min)))) 751 (let ((size (- (point-max) (point-min))))
757 (goto-char (if arg 752 (goto-char (if arg
758 (+ (point-min) 753 (+ (point-min)
759 (if (> size 10000) 754 (if (> size 10000)
760 ;; Avoid overflow for large buffer sizes! 755 ;; Avoid overflow for large buffer sizes!
978 (define-key function-key-map [M-delete] 973 (define-key function-key-map [M-delete]
979 pc-select-old-M-delete-binding)) 974 pc-select-old-M-delete-binding))
980 (setq pc-select-key-bindings-alist nil 975 (setq pc-select-key-bindings-alist nil
981 pc-select-saved-settings-alist nil)))) 976 pc-select-saved-settings-alist nil))))
982 977
983
984 ;;;###autoload
985 (defcustom pc-selection-mode nil
986 "Toggle PC Selection mode.
987 Change mark behavior to emulate Motif, MAC or MS-Windows cut and paste style,
988 and cursor movement commands.
989 This mode enables Delete Selection mode and Transient Mark mode.
990 Setting this variable directly does not take effect;
991 you must modify it using \\[customize] or \\[pc-selection-mode]."
992 :set (lambda (symbol value)
993 (pc-selection-mode (if value 1 -1)))
994 :initialize 'custom-initialize-default
995 :type 'boolean
996 :group 'pc-select
997 :require 'pc-select)
998
999 ;; arch-tag: 10697b70-ae07-4f3e-ad23-7814a3f418c2 978 ;; arch-tag: 10697b70-ae07-4f3e-ad23-7814a3f418c2
1000 ;;; pc-select.el ends here 979 ;;; pc-select.el ends here