aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1996-12-08 08:18:52 +0000
committerRichard M. Stallman1996-12-08 08:18:52 +0000
commitc9ed721db0e2c1b97969c88f3c7405ce4ec7a522 (patch)
tree6795bc28fbee6cefba73bfaad99142f1d8758fe0 /src
parent345d9d7376c5f09febec087e3e60fadedb284b71 (diff)
downloademacs-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.c63
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
256DEFUN ("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\
259With argument N not nil or 1, move forward N - 1 lines first.\n\
260If scan reaches end of buffer, return that position.\n\
261This 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
280DEFUN ("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\
283With argument N not nil or 1, move forward N - 1 lines first.\n\
284If scan reaches end of buffer, return that position.\n\
285This 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
256Lisp_Object 298Lisp_Object
257save_excursion_save () 299save_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
544DEFUN ("user-full-name", Fuser_full_name, Suser_full_name, 0, 0, 0, 586DEFUN ("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 () 588If optional argument UID is an integer, return the full name of the user\n\
589with 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
551DEFUN ("system-name", Fsystem_name, Ssystem_name, 0, 0, 0, 603DEFUN ("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);