Fix kkp, again
This commit is contained in:
		
							
								
								
									
										38
									
								
								init.el
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								init.el
									
									
									
									
									
								
							@ -409,22 +409,30 @@ directory. Otherwise, run `find-file' on that file."
 | 
				
			|||||||
  (defun my/-kkp-fix-map-y-or-n-p (oldfun &rest args)
 | 
					  (defun my/-kkp-fix-map-y-or-n-p (oldfun &rest args)
 | 
				
			||||||
    "Fix `map-y-or-n-p' when used in a terminal with kkp enabled."
 | 
					    "Fix `map-y-or-n-p' when used in a terminal with kkp enabled."
 | 
				
			||||||
    (let ((status (kkp--terminal-has-active-kkp-p)))
 | 
					    (let ((status (kkp--terminal-has-active-kkp-p)))
 | 
				
			||||||
      (unwind-protect
 | 
					      (condition-case err
 | 
				
			||||||
          (progn
 | 
					          (progn
 | 
				
			||||||
            (when status (kkp-disable-in-terminal))
 | 
					            (when status (kkp-disable-in-terminal))
 | 
				
			||||||
            (apply oldfun args))
 | 
					            (apply oldfun args))
 | 
				
			||||||
        (when (and status (not (kkp--terminal-has-active-kkp-p)))
 | 
					        (quit
 | 
				
			||||||
          ;; this does async stuff that will make kitty send characters after
 | 
					         ;; We won't die in this case, so just re-enable kkp
 | 
				
			||||||
          ;; Emacs exits. We prevent that by not re-enabling if this frame (or
 | 
					         (when (and status (not (kkp--terminal-has-active-kkp-p)))
 | 
				
			||||||
          ;; Emacs) is about to die
 | 
					           (kkp-enable-in-terminal))
 | 
				
			||||||
          (let ((will-die))
 | 
					         (signal 'quit nil))
 | 
				
			||||||
            (mapbacktrace
 | 
					        (t
 | 
				
			||||||
             (lambda (_evald func _args _flags)
 | 
					         (when (and status (not (kkp--terminal-has-active-kkp-p)))
 | 
				
			||||||
               (when (or (eq func 'save-buffers-kill-emacs)
 | 
					           ;; this does async stuff that will make kitty send characters after
 | 
				
			||||||
                         (eq func 'server-save-buffers-kill-terminal))
 | 
					           ;; Emacs exits. We prevent that by not re-enabling if this frame (or
 | 
				
			||||||
                 (setq will-die t))))
 | 
					           ;; Emacs) is about to die
 | 
				
			||||||
            (unless will-die
 | 
					           (let ((will-die))
 | 
				
			||||||
              (kkp-enable-in-terminal)))))))
 | 
					             (mapbacktrace
 | 
				
			||||||
 | 
					              (lambda (_evald func _args _flags)
 | 
				
			||||||
 | 
					                (when (or (eq func 'save-buffers-kill-emacs)
 | 
				
			||||||
 | 
					                          (eq func 'server-save-buffers-kill-terminal))
 | 
				
			||||||
 | 
					                  (setq will-die t))))
 | 
				
			||||||
 | 
					             (unless will-die
 | 
				
			||||||
 | 
					               (kkp-enable-in-terminal))))
 | 
				
			||||||
 | 
					         (when err
 | 
				
			||||||
 | 
					           (signal (car err) (cdr err)))))))
 | 
				
			||||||
  (advice-add #'map-y-or-n-p :around
 | 
					  (advice-add #'map-y-or-n-p :around
 | 
				
			||||||
              #'my/-kkp-fix-map-y-or-n-p))
 | 
					              #'my/-kkp-fix-map-y-or-n-p))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -524,7 +532,7 @@ With NO-EDGE, return nil if beg or end fall on the edge of the range."
 | 
				
			|||||||
    (save-excursion
 | 
					    (save-excursion
 | 
				
			||||||
      ;; this fixes that fact that `thing-at-point-bounds-of-string-at-point'
 | 
					      ;; this fixes that fact that `thing-at-point-bounds-of-string-at-point'
 | 
				
			||||||
      ;; errors if called at the end of the buffer
 | 
					      ;; errors if called at the end of the buffer
 | 
				
			||||||
      (condition-case _
 | 
					      (condition-case nil
 | 
				
			||||||
          (let ((sb (progn (goto-char beg) (bounds-of-thing-at-point thing)))
 | 
					          (let ((sb (progn (goto-char beg) (bounds-of-thing-at-point thing)))
 | 
				
			||||||
                (eb (progn (goto-char end) (bounds-of-thing-at-point thing))))
 | 
					                (eb (progn (goto-char end) (bounds-of-thing-at-point thing))))
 | 
				
			||||||
            (and sb eb (equal sb eb)
 | 
					            (and sb eb (equal sb eb)
 | 
				
			||||||
@ -1370,7 +1378,7 @@ entry, return nil."
 | 
				
			|||||||
    ;; go to top level and check if the character at point is {
 | 
					    ;; go to top level and check if the character at point is {
 | 
				
			||||||
    (let ((start-pos (point))
 | 
					    (let ((start-pos (point))
 | 
				
			||||||
          (last-valid (point)))
 | 
					          (last-valid (point)))
 | 
				
			||||||
      (condition-case _
 | 
					      (condition-case nil
 | 
				
			||||||
          (while t
 | 
					          (while t
 | 
				
			||||||
            (backward-up-list 1 t t)
 | 
					            (backward-up-list 1 t t)
 | 
				
			||||||
            (setq last-valid (point)))
 | 
					            (setq last-valid (point)))
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user