Skip to main content
edited tags
Source Link
Drew
  • 79.1k
  • 10
  • 123
  • 257

how allowdoes optional argument `ALLOW-extendEXTEND` in 'mark`mark-word worksword` work?

I am switching from VIM to emacsEmacs for just a couple weeks and trying to write some elispElisp. Having difficulties to adapt, I am exploring different options to do marking and reached this function.

it's pretty straight forward except allow-extend. It seems to me for this function to work, allow-extend needs to be empty. But when we do interaction, we don't really provide any prefix key to it. 

So why would allow-extend would be non nil in this case? Also how does "P\np" workswork here?

how allow-extend in 'mark-word works?

I am switching from VIM to emacs for just a couple weeks and trying to write some elisp. Having difficulties to adapt, I am exploring different options to do marking and reached this function.

it's pretty straight forward except allow-extend. It seems to me for this function to work, allow-extend needs to be empty. But when we do interaction, we don't really provide any prefix key to it. So why allow-extend would be non nil in this case? Also how "P\np" works here?

how does optional argument `ALLOW-EXTEND` in `mark-word` work?

I am switching from VIM to Emacs for just a couple weeks and trying to write some Elisp. Having difficulties to adapt, I am exploring different options to do marking and reached this function.

it's pretty straight forward except allow-extend. It seems to me for this function to work, allow-extend needs to be empty. But when we do interaction, we don't really provide any prefix key to it. 

So why would allow-extend be non nil in this case? Also how does "P\np" work here?

Source Link
Jason Hu
  • 201
  • 1
  • 8

how allow-extend in 'mark-word works?

I am switching from VIM to emacs for just a couple weeks and trying to write some elisp. Having difficulties to adapt, I am exploring different options to do marking and reached this function.

(defun mark-word (&optional arg allow-extend)                          
  "Set mark ARG words away from point.                                 
The place mark goes is the same place \\[forward-word] would           
move to with the same argument.                                        
Interactively, if this command is repeated                             
or (in Transient Mark mode) if the mark is active,                     
it marks the next ARG words after the ones already marked."            
  (interactive "P\np")                                                 
  (cond ((and allow-extend                                             
              (or (and (eq last-command this-command) (mark t))        
                  (region-active-p)))                                  
         (setq arg (if arg (prefix-numeric-value arg)                  
                     (if (< (mark) (point)) -1 1)))                    
         (set-mark                                                     
          (save-excursion                                              
            (goto-char (mark))                                         
            (forward-word arg)                                         
            (point))))                                                 
        (t                                                             
         (push-mark                                                    
          (save-excursion                                              
            (forward-word (prefix-numeric-value arg))                  
            (point))                                                   
          nil t))))                                                    

it's pretty straight forward except allow-extend. It seems to me for this function to work, allow-extend needs to be empty. But when we do interaction, we don't really provide any prefix key to it. So why allow-extend would be non nil in this case? Also how "P\np" works here?