diff options
| author | Noam Postavsky | 2018-05-25 08:40:55 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2018-06-12 07:40:33 -0400 |
| commit | c912db0836f6975519dea57fb0a4adc2988da1b1 (patch) | |
| tree | 8a58bce003464b5f367beb9e7a4f8555f843d88b /src | |
| parent | 2634d867b66ddff568048ce664f003ae8950bdfa (diff) | |
| download | emacs-c912db0836f6975519dea57fb0a4adc2988da1b1.tar.gz emacs-c912db0836f6975519dea57fb0a4adc2988da1b1.zip | |
Give warning if losing value to defvaralias (Bug#5950)
* src/eval.c (Fdefvaralias): Call `display-warning' if the alias
target has a non-eq value to the variable being aliased.
* test/src/eval-tests.el (defvaralias-overwrite-warning): New test.
Diffstat (limited to 'src')
| -rw-r--r-- | src/eval.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c index 86011a234c0..5c7cb3196a6 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -623,6 +623,16 @@ The return value is BASE-VARIABLE. */) | |||
| 623 | if (NILP (Fboundp (base_variable))) | 623 | if (NILP (Fboundp (base_variable))) |
| 624 | set_internal (base_variable, find_symbol_value (new_alias), | 624 | set_internal (base_variable, find_symbol_value (new_alias), |
| 625 | Qnil, SET_INTERNAL_BIND); | 625 | Qnil, SET_INTERNAL_BIND); |
| 626 | else if (!NILP (Fboundp (new_alias)) | ||
| 627 | && !EQ (find_symbol_value (new_alias), | ||
| 628 | find_symbol_value (base_variable))) | ||
| 629 | call2 (intern ("display-warning"), | ||
| 630 | list3 (intern ("defvaralias"), intern ("losing-value"), new_alias), | ||
| 631 | CALLN (Fformat_message, | ||
| 632 | build_string | ||
| 633 | ("Overwriting value of `%s' by aliasing to `%s'"), | ||
| 634 | new_alias, base_variable)); | ||
| 635 | |||
| 626 | { | 636 | { |
| 627 | union specbinding *p; | 637 | union specbinding *p; |
| 628 | 638 | ||