diff options
| author | Richard M. Stallman | 1996-12-08 08:18:52 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-12-08 08:18:52 +0000 |
| commit | c9ed721db0e2c1b97969c88f3c7405ce4ec7a522 (patch) | |
| tree | 6795bc28fbee6cefba73bfaad99142f1d8758fe0 /src | |
| parent | 345d9d7376c5f09febec087e3e60fadedb284b71 (diff) | |
| download | emacs-c9ed721db0e2c1b97969c88f3c7405ce4ec7a522.tar.gz emacs-c9ed721db0e2c1b97969c88f3c7405ce4ec7a522.zip | |
(Fline_beginning_position, Fline_end_position): New fns.
(Fuser_full_name): Accept an optional UID and return
the full name of that user instead.
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/src/editfns.c b/src/editfns.c index 64522ecbf34..699cadc6046 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -252,7 +252,49 @@ If you set the marker not to point anywhere, the buffer will have no mark.") | |||
| 252 | { | 252 | { |
| 253 | return current_buffer->mark; | 253 | return current_buffer->mark; |
| 254 | } | 254 | } |
| 255 | |||
| 256 | DEFUN ("line-beginning-position", Fline_beginning_position, Sline_beginning_position, | ||
| 257 | 0, 1, 0, | ||
| 258 | "Return the character position of the first character on the current line.\n\ | ||
| 259 | With argument N not nil or 1, move forward N - 1 lines first.\n\ | ||
| 260 | If scan reaches end of buffer, return that position.\n\ | ||
| 261 | This function does not move point.") | ||
| 262 | (n) | ||
| 263 | Lisp_Object n; | ||
| 264 | { | ||
| 265 | register int orig, end; | ||
| 266 | |||
| 267 | if (NILP (n)) | ||
| 268 | XSETFASTINT (n, 1); | ||
| 269 | else | ||
| 270 | CHECK_NUMBER (n, 0); | ||
| 271 | |||
| 272 | orig = PT; | ||
| 273 | Fforward_line (make_number (XINT (n) - 1)); | ||
| 274 | end = PT; | ||
| 275 | SET_PT (orig); | ||
| 255 | 276 | ||
| 277 | return make_number (end); | ||
| 278 | } | ||
| 279 | |||
| 280 | DEFUN ("line-end-position", Fline_end_position, Sline_end_position, | ||
| 281 | 0, 1, 0, | ||
| 282 | "Return the character position of the last character on the current line.\n\ | ||
| 283 | With argument N not nil or 1, move forward N - 1 lines first.\n\ | ||
| 284 | If scan reaches end of buffer, return that position.\n\ | ||
| 285 | This function does not move point.") | ||
| 286 | (n) | ||
| 287 | Lisp_Object n; | ||
| 288 | { | ||
| 289 | if (NILP (n)) | ||
| 290 | XSETFASTINT (n, 1); | ||
| 291 | else | ||
| 292 | CHECK_NUMBER (n, 0); | ||
| 293 | |||
| 294 | return make_number (find_before_next_newline | ||
| 295 | (PT, 0, XINT (n) - (XINT (n) <= 0))); | ||
| 296 | } | ||
| 297 | |||
| 256 | Lisp_Object | 298 | Lisp_Object |
| 257 | save_excursion_save () | 299 | save_excursion_save () |
| 258 | { | 300 | { |
| @@ -541,11 +583,21 @@ DEFUN ("user-real-uid", Fuser_real_uid, Suser_real_uid, 0, 0, 0, | |||
| 541 | return make_number (getuid ()); | 583 | return make_number (getuid ()); |
| 542 | } | 584 | } |
| 543 | 585 | ||
| 544 | DEFUN ("user-full-name", Fuser_full_name, Suser_full_name, 0, 0, 0, | 586 | DEFUN ("user-full-name", Fuser_full_name, Suser_full_name, 0, 1, 0, |
| 545 | "Return the full name of the user logged in, as a string.") | 587 | "Return the full name of the user logged in, as a string.\n\ |
| 546 | () | 588 | If optional argument UID is an integer, return the full name of the user\n\ |
| 589 | with that uid, or nil if there is no such user.") | ||
| 590 | (uid) | ||
| 591 | Lisp_Object uid; | ||
| 547 | { | 592 | { |
| 548 | return Vuser_full_name; | 593 | struct passwd *pw; |
| 594 | |||
| 595 | if (NILP (uid)) | ||
| 596 | return Vuser_full_name; | ||
| 597 | |||
| 598 | CHECK_NUMBER (uid, 0); | ||
| 599 | pw = (struct passwd *) getpwuid (XINT (uid)); | ||
| 600 | return (pw ? build_string (pw->pw_gecos) : Qnil); | ||
| 549 | } | 601 | } |
| 550 | 602 | ||
| 551 | DEFUN ("system-name", Fsystem_name, Ssystem_name, 0, 0, 0, | 603 | DEFUN ("system-name", Fsystem_name, Ssystem_name, 0, 0, 0, |
| @@ -2537,6 +2589,9 @@ functions if all the text being accessed has this property."); | |||
| 2537 | defsubr (&Spoint_min_marker); | 2589 | defsubr (&Spoint_min_marker); |
| 2538 | defsubr (&Spoint_max_marker); | 2590 | defsubr (&Spoint_max_marker); |
| 2539 | 2591 | ||
| 2592 | defsubr (&Sline_beginning_position); | ||
| 2593 | defsubr (&Sline_end_position); | ||
| 2594 | |||
| 2540 | defsubr (&Sbobp); | 2595 | defsubr (&Sbobp); |
| 2541 | defsubr (&Seobp); | 2596 | defsubr (&Seobp); |
| 2542 | defsubr (&Sbolp); | 2597 | defsubr (&Sbolp); |