5656 (sit-for 1 )
5757 nil )))
5858 (save-excursion
59- (if ( not ( memq (char-syntax (preceding-char )) '(?w ?_ ) ))
60- (while (not (looking-at " \\ sw\\ |\\ s_\\ |\\ '" ))
61- (forward-char 1 )))
59+ (unless ( memq (char-syntax (preceding-char )) '(?w ?_ ))
60+ (while (not (looking-at " \\ sw\\ |\\ s_\\ |\\ '" ))
61+ (forward-char 1 )))
6262 (while (looking-at " \\ sw\\ |\\ s_" )
6363 (forward-char 1 ))
64- (if (re-search-backward " \\ sw\\ |\\ s_" nil t )
65- (regexp-quote
66- (progn (forward-char 1 )
67- (buffer-substring (point )
68- (progn (forward-sexp -1 )
69- (while (looking-at " \\ s'" )
70- (forward-char 1 ))
71- (point )))))
72- nil )))))
64+ (when (re-search-backward " \\ sw\\ |\\ s_" nil t )
65+ (forward-char 1 )
66+ (regexp-quote (buffer-substring (point )
67+ (progn (forward-sexp -1 )
68+ (while (looking-at " \\ s'" )
69+ (forward-char 1 ))
70+ (point )))))))))
7371
7472(unless (fboundp 'find-tag--default )
7573 (defun find-tag--default ()
76- (funcall (or (if (fboundp find-tag-default-function) find-tag-default-function)
74+ (funcall (or (when (fboundp find-tag-default-function) find-tag-default-function)
7775 (get major-mode 'find-tag-default-function )
7876 'find-tag-default ))))
7977(defalias 'hargs:find-tag-default 'find-tag--default )
@@ -86,9 +84,9 @@ Return nil if ACTION is not a list or `byte-code' object, has no
8684interactive form or takes no arguments."
8785 (and (or (hypb:emacs-byte-code-p action) (listp action))
8886 (let ((interactive-form (action:commandp action)))
89- (if interactive-form
90- (action:path-args-rel
91- (hargs:iform-read interactive-form modifying))))))
87+ (when interactive-form
88+ (action:path-args-rel
89+ (hargs:iform-read interactive-form modifying))))))
9290
9391(defun hargs:buffer-substring (start end )
9492 (let ((string (buffer-substring-no-properties start end)))
@@ -185,8 +183,8 @@ element of the list is always the symbol 'args."
185183 ((eq (aref interactive-entry 0 ) ?+ )
186184 (setq cmd (aref interactive-entry 1 )
187185 prompt (format (substring interactive-entry 2 ) prior-arg)
188- func (if (< cmd (length hargs:iform-extensions-vector))
189- (aref hargs:iform-extensions-vector cmd)))
186+ func (when (< cmd (length hargs:iform-extensions-vector))
187+ (aref hargs:iform-extensions-vector cmd)))
190188 (if func
191189 (funcall func prompt default )
192190 (error
@@ -196,8 +194,8 @@ element of the list is always the symbol 'args."
196194 (t (setq cmd (aref interactive-entry 0 )
197195 prompt
198196 (format (substring interactive-entry 1 ) prior-arg)
199- func (if (< cmd (length hargs:iform-vector))
200- (aref hargs:iform-vector cmd)))
197+ func (when (< cmd (length hargs:iform-vector))
198+ (aref hargs:iform-vector cmd)))
201199 (if func
202200 (funcall func prompt default )
203201 (error
@@ -242,8 +240,8 @@ Optional DEFAULT-PROMPT is used to describe default value."
242240 (save-window-excursion
243241 (set-buffer (window-buffer (minibuffer-window )))
244242 (setq hargs:string-to-complete (minibuffer-contents-no-properties ))
245- (if (equal hargs:string-to-complete " " )
246- (setq hargs:string-to-complete nil ))))
243+ (when (equal hargs:string-to-complete " " )
244+ (setq hargs:string-to-complete nil ))))
247245
248246(defun hargs:unset-string-to-complete ()
249247 " Remove any value from `hargs:string-to-complete' ."
@@ -304,7 +302,7 @@ Handles all of the interactive argument types that `hargs:iform-read' does."
304302 (list (hargs:at-p)))))
305303 ((eq hargs:reading-p 'kvspec )
306304 (read-string " Koutline view spec: "
307- (if (boundp 'kvspec:current ) kvspec:current)))
305+ (when (boundp 'kvspec:current ) kvspec:current)))
308306 ((eolp ) nil )
309307 ((and (eq hargs:reading-p 'hmenu )
310308 (eq (selected-window ) (minibuffer-window )))
@@ -339,7 +337,7 @@ Handles all of the interactive argument types that `hargs:iform-read' does."
339337 ; ; Unquoted remote file name.
340338 ((hpath:is-p (hpath:remote-at-p) 'file ))
341339 ; ; Possibly non-existent file name
342- ((if no-default (hpath:at-p 'file 'non-exist )))
340+ ((when no-default (hpath:at-p 'file 'non-exist )))
343341 (no-default nil )
344342 ((buffer-file-name ))
345343 ))
@@ -357,7 +355,7 @@ Handles all of the interactive argument types that `hargs:iform-read' does."
357355 ; ; Unquoted remote directory name.
358356 ((hpath:is-p (hpath:remote-at-p) 'directory ))
359357 ; ; Possibly non-existent directory name
360- ((if no-default (hpath:at-p 'directory 'non-exist )))
358+ ((when no-default (hpath:at-p 'directory 'non-exist )))
361359 (no-default nil )
362360 (default-directory )
363361 ))
@@ -375,26 +373,26 @@ Handles all of the interactive argument types that `hargs:iform-read' does."
375373 (car (set:member name (htype:names 'ibtypes )))))
376374 ((eq hargs:reading-p 'sexpression ) (hargs:sexpression-p))
377375 ((memq hargs:reading-p '(Info-index-item Info-node))
378- (if (eq major-mode 'Info-mode )
379- (let ((file (Info-current-filename-sans-extension))
380- (node (cond ((Info-note-at-p))
381- ((Info-menu-item-at-p)
382- (save-excursion
383- (beginning-of-line )
384- (forward-char 2 )
385- (Info-extract-menu-node-name nil (Info-index-node ))))
386- (t Info-current-node))))
387- (cond ((and (stringp node) (string-match " \\ `\( " node))
388- node)
389- (file
390- (concat " (" file " )" node))
391- (t node)))))
376+ (when (eq major-mode 'Info-mode )
377+ (let ((file (Info-current-filename-sans-extension))
378+ (node (cond ((Info-note-at-p))
379+ ((Info-menu-item-at-p)
380+ (save-excursion
381+ (beginning-of-line )
382+ (forward-char 2 )
383+ (Info-extract-menu-node-name nil (Info-index-node ))))
384+ (t Info-current-node))))
385+ (cond ((and (stringp node) (string-match " \\ `\( " node))
386+ node)
387+ (file
388+ (concat " (" file " )" node))
389+ (t node)))))
392390 ((eq hargs:reading-p 'mail )
393391 (and (hmail:reader-p) buffer-file-name
394392 (prin1-to-string (list (rmail:msg-id-get) buffer-file-name))))
395393 ((eq hargs:reading-p 'symbol )
396394 (let ((sym (hargs:find-tag-default)))
397- (if (or (fboundp sym) (boundp sym)) sym)))
395+ (when (or (fboundp sym) (boundp sym)) sym)))
398396 ((eq hargs:reading-p 'buffer )
399397 (hargs:find-tag-default))
400398 ((eq hargs:reading-p 'character )
@@ -405,76 +403,77 @@ Handles all of the interactive argument types that `hargs:iform-read' does."
405403 (when key-seq (kbd-key:normalize key-seq))))
406404 ((eq hargs:reading-p 'integer )
407405 (save-excursion (skip-chars-backward " -0-9" )
408- (if (looking-at " -?[0-9]+" )
409- (read (current-buffer )))))))
406+ (when (looking-at " -?[0-9]+" )
407+ (read (current-buffer )))))))
410408
411409(defun hargs:completion (&optional no-insert )
412410 " If in the completions buffer, return completion at point.
413411Also insert unless optional NO-INSERT is non-nil.
414412Insert in minibuffer if active or in other window if minibuffer is inactive."
415413 (interactive '(nil ))
416- (if (or (string-match " [* ]Completions\\ *\\ '" (buffer-name ))
417- (eq major-mode 'completion-mode ))
418- (let ((opoint (point ))
419- (owind (selected-window )))
420- (if (re-search-backward " ^\\ |\t \\ | [ \t ]" nil t )
421- (let ((insert-window
422- (cond ((> (minibuffer-depth ) 0 )
423- (minibuffer-window ))
424- ((not (eq (selected-window ) (next-window nil )))
425- (next-window nil ))))
426- (bury-completions)
427- (entry))
428- (skip-chars-forward " \t " )
429- (if (and insert-window
430- ; ; Allow single spaces in the middle of completions
431- ; ; since completions always end with either a tab,
432- ; ; newline or two whitespace characters.
433- (looking-at
434- " [^ \t\n ]+\\ ( [^ \t\n ]+\\ )*\\ ( [ \t\n ]\\ |[\t\n ]\\ |\\ '\\ )" ))
435- (progn (setq entry (buffer-substring (match-beginning 0 )
436- (match-beginning 2 )))
437- (select-window insert-window)
438- (let ((str (or hargs:string-to-complete
439- (buffer-substring
440- (point )
441- (save-excursion (beginning-of-line )
442- (point ))))))
443- (cond
444- ((and (eq (selected-window ) (minibuffer-window )))
445- (cond ((string-match (concat
446- (regexp-quote entry)
447- " \\ '" )
448- str)
449- ; ; If entry matches tail of minibuffer
450- ; ; prefix already, then return minibuffer
451- ; ; contents as the entry.
452- (setq entry str))
453- ; ;
454- ((string-match " [~/][^/]*\\ '" str)
455- ; ; file or directory entry
456- (setq entry
457- (concat
458- (substring
459- str 0
460- (1+ (match-beginning 0 )))
461- entry))))
462- (or no-insert
463- (if entry (progn (erase-buffer )
464- (insert entry)))))
465- ; ; In buffer, non-minibuffer completion.
466- ; ; Only insert entry if last buffer line does
467- ; ; not end in entry.
468- (no-insert)
469- ((or (string-match
470- (concat (regexp-quote entry) " \\ '" ) str)
471- (null entry))
472- (setq bury-completions t ))
473- (t (insert entry))))))
474- (select-window owind) (goto-char opoint)
475- (if bury-completions
476- (progn (bury-buffer nil ) (delete-window )))
477- entry)))))
414+ (when (or (string-match " [* ]Completions\\ *\\ '" (buffer-name ))
415+ (eq major-mode 'completion-mode ))
416+ (let ((opoint (point ))
417+ (owind (selected-window )))
418+ (when (re-search-backward " ^\\ |\t \\ | [ \t ]" nil t )
419+ (let ((insert-window
420+ (cond ((> (minibuffer-depth ) 0 )
421+ (minibuffer-window ))
422+ ((not (eq (selected-window ) (next-window nil )))
423+ (next-window nil ))))
424+ (bury-completions)
425+ (entry))
426+ (skip-chars-forward " \t " )
427+ (when (and insert-window
428+ ; ; Allow single spaces in the middle of completions
429+ ; ; since completions always end with either a tab,
430+ ; ; newline or two whitespace characters.
431+ (looking-at
432+ " [^ \t\n ]+\\ ( [^ \t\n ]+\\ )*\\ ( [ \t\n ]\\ |[\t\n ]\\ |\\ '\\ )" ))
433+ (setq entry (buffer-substring (match-beginning 0 )
434+ (match-beginning 2 )))
435+ (select-window insert-window)
436+ (let ((str (or hargs:string-to-complete
437+ (buffer-substring
438+ (point )
439+ (save-excursion (beginning-of-line )
440+ (point ))))))
441+ (cond
442+ ((and (eq (selected-window ) (minibuffer-window )))
443+ (cond ((string-match (concat
444+ (regexp-quote entry)
445+ " \\ '" )
446+ str)
447+ ; ; If entry matches tail of minibuffer
448+ ; ; prefix already, then return minibuffer
449+ ; ; contents as the entry.
450+ (setq entry str))
451+ ; ;
452+ ((string-match " [~/][^/]*\\ '" str)
453+ ; ; file or directory entry
454+ (setq entry
455+ (concat
456+ (substring
457+ str 0
458+ (1+ (match-beginning 0 )))
459+ entry))))
460+ (or no-insert
461+ (if entry (progn (erase-buffer )
462+ (insert entry)))))
463+ ; ; In buffer, non-minibuffer completion.
464+ ; ; Only insert entry if last buffer line does
465+ ; ; not end in entry.
466+ (no-insert)
467+ ((or (string-match
468+ (concat (regexp-quote entry) " \\ '" ) str)
469+ (null entry))
470+ (setq bury-completions t ))
471+ (t (insert entry)))))
472+ (select-window owind) (goto-char opoint)
473+ (when bury-completions
474+ (bury-buffer nil )
475+ (delete-window ))
476+ entry)))))
478477
479478(defun hargs:iform-read (iform &optional modifying )
480479 " Read action arguments according to IFORM, a list with car = 'interactive.
@@ -594,12 +593,13 @@ string read or nil."
594593 (and predicate (not (funcall predicate val)))))
595594 (if bad-val (setq bad-val nil ) (setq default val))
596595 (beep )
597- (if err (progn (message err) (sit-for 3 ))))
596+ (when err
597+ (message err)
598+ (sit-for 3 )))
598599 val)
599600 (setq hargs:reading-p prev-reading-p)
600601 (select-window owind)
601- (switch-to-buffer obuf)
602- )))
602+ (switch-to-buffer obuf))))
603603
604604(defun hargs:read-match (prompt collection
605605 &optional predicate must-match initial-input val-type )
@@ -635,32 +635,32 @@ the current minibuffer argument, otherwise, the minibuffer is erased
635635and value is inserted there.
636636Optional ASSIST-FLAG non-nil triggers display of Hyperbole menu item
637637help when appropriate."
638- (if (and (> (minibuffer-depth ) 0 ) (or value (setq value (hargs:at-p))))
639- (let ((owind (selected-window )) (back-to)
640- (str-value (and value (format " %s " value)))
641- ; ; This command requires recursive minibuffers.
642- (enable-recursive-minibuffers t ))
643- (unwind-protect
644- (progn
645- (select-window (minibuffer-window ))
646- (set-buffer (window-buffer (minibuffer-window )))
647- (cond
648- ; ;
649- ; ; Selecting a menu item
650- ((eq hargs:reading-p 'hmenu )
651- (if assist-flag (setq hargs:reading-p 'hmenu-help ))
652- (hui:menu-enter str-value))
653- ; ;
654- ; ; Enter existing value into the minibuffer as the desired parameter.
655- ((string-equal str-value (minibuffer-contents ))
656- (exit-minibuffer ))
657- ; ;
658- ; ; Clear minibuffer and insert value.
659- (t (delete-minibuffer-contents )
660- (insert str-value)
661- (setq back-to t )))
662- value)
663- ( if back-to (select-window owind))))))
638+ (when (and (> (minibuffer-depth ) 0 ) (or value (setq value (hargs:at-p))))
639+ (let ((owind (selected-window )) (back-to)
640+ (str-value (and value (format " %s " value)))
641+ ; ; This command requires recursive minibuffers.
642+ (enable-recursive-minibuffers t ))
643+ (unwind-protect
644+ (progn
645+ (select-window (minibuffer-window ))
646+ (set-buffer (window-buffer (minibuffer-window )))
647+ (cond
648+ ; ;
649+ ; ; Selecting a menu item
650+ ((eq hargs:reading-p 'hmenu )
651+ (if assist-flag (setq hargs:reading-p 'hmenu-help ))
652+ (hui:menu-enter str-value))
653+ ; ;
654+ ; ; Enter existing value into the minibuffer as the desired parameter.
655+ ((string-equal str-value (minibuffer-contents ))
656+ (exit-minibuffer ))
657+ ; ;
658+ ; ; Clear minibuffer and insert value.
659+ (t (delete-minibuffer-contents )
660+ (insert str-value)
661+ (setq back-to t )))
662+ value)
663+ ( when back-to (select-window owind))))))
664664
665665; ;; ************************************************************************
666666; ;; Private variables
0 commit comments